Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Some questions about UDP, Bitfields and packet data.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 gimp   Members   -  Reputation: 142

Like
Likes
Like

Posted 01 May 2000 - 12:51 PM

Hello, thanks for taking the time to have a read. A few questions... -Does anyone know of any tutorials about UPD? I''ve been reading up and it looks like I only have to upen a single socket to recieve UPD datagrams. -What is a bitfield? Is it just like BYTE data[16] -When I collect packets on the server and send them to all clients, how will my code at the other end know where each hunk of data ends? Are NULL''s really unique when I''m setting all bits? Should I send the first part of the hunk as a data size in bytes? Many thanks.. Chris

Sponsor:

#2 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 02 May 2000 - 09:10 AM

Check out this site for some info on how a server - client game is structured.

http://www.codewhore.com/

You can organize the data transfer between your client and server around serialized objects, if your using objects. Implement a write and read function per object which recives an input or output stream from which it can read or write. A network connection can be abstracted to function like any other stream (ie. file stream). You''ll need to preface the packet stream with the packet id so you know what packet type it is. You can either embeded the packet size in the stream or give it a fixed size at compile time, both are easily implemented. This is just one way to do it.

You can use an int to represent a bitfield. They are usually 32 bits on modern cpus. I suggest creatting a bitfield datatype class. For instance

class Bitfield {
public:

Bitfield(){field = 0;}
virtual ~Bitfield();

void activate_flags(unsigned int flag)
{
field /= flag;
}

void deactivate_flags(unsigend int flag)
{
field &= ~flag;
}

unsigned int check_flags(unsigend int flag)
{
return (flag&field);
}

//serailzing functions as explained above

bool write(outstream *out);
bool read(instream *in);

private:

unsigned int field;

};

This should give you some ideas about how to impelement a bitfield class. I dont know if the above compiles i just wrote it, but it should. You can set more than one flag at a time by combining them like

bitfield.activate_flag(FLAG1/FLAG2/FLAG3);

using the logical or.


Good Luck.

-ddn



#3 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 02 May 2000 - 09:13 AM

apparenlty this messagebaord doesn''t allow you to use the logical or operator and replaces it with a backslash. Well just make sure to replace the (/) with the logical or operator.

Good Luck

-ddn




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS