Jump to content
  • Advertisement
Sign in to follow this  
deftware

Developing UDP netcode on one machine?

This topic is 3252 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I tried running my project on one machine, two instances of it. One instance I host a game, the other I connect to it. Both instances are communicating over the same port, would that cause packets to get mixed up and confused between the instances ? EG: some client->server packets end up going back to the client, and viceversa ? There wasn't anything about this in the FAQ. Thanks for help.

Share this post


Link to post
Share on other sites
Advertisement
Usually, clients don't use a specific port - instead they pick a random port number and initiate contact with the server. Use 0 as a port and the underlying network API will pick a random port for you.

Share this post


Link to post
Share on other sites
use a specific port for the host, and a arbitrary / unspecified port for the client and bob's your uncle. put 0 in, the system will pick a port for you.

Share this post


Link to post
Share on other sites

Hey, thanks guys, that fixed a few things, but apparently I'm still not processing / generating my packets properly as the remote client quits when I start sending packets containing position/velocity data. The hunt continues.

Share this post


Link to post
Share on other sites


I got it all working.. I found what was making it quit out:


if(flags & UP_ORIGIN)
{
e->realorigin.x = *(float *)&data[pos]; pos+=4;
e->realorigin.y = *(float *)&data[pos]; pos+=4;
e->realorigin.z = *(float *)&data[pos]; pos+=4;
}


I forgot the & infront of data... so much for sleep-deprived coding!

Share this post


Link to post
Share on other sites
Is there a reason why your debugger didn't simply stop at the bad pointer dereference and show you the source of the segfault?
If so, you should figure out what that is. With any crash, you should immediately be told what line is crashing, and why, or your development won't ever be efficient.

Share this post


Link to post
Share on other sites
Quote:
Original post by radioteeth


Personal preference to avoid debuggers :)


Hope you don't plan on trying to get a job in the software development industry.

Share this post


Link to post
Share on other sites


'Personal' != 'Work'

I actually write firmware for work, and using a debugger for that is absolutely essential as devices I am working tend to only have LED lights.. But on a computer I usually just logprint stuff..

Thanks again guys.. I am having a problem with the server suddenly receiving tons of garbage data packets from nowhere when a client disconnects. This happens inconsistently, so sometimes it works fine, but I think it has something to do with handling a late packet that arrives after a client disconnects.. hrmm..

What specific situation would cause a recvfrom to be loaded full of huge nothingness packets from nowhere ?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!