Sign in to follow this  

UDP - Returning data.

This topic is 1369 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

I'm writing a simple command-line based chat client using C and SDL_net. This page has been useful: http://content.gpwiki.org/SDL:Tutorial:Using_SDL_net#Using_UDP

 

The code on that page works well for clients connecting to a host and sending messages to the host. What I am now trying to do is have the host send data back to each client.

 

It seems like it would be relatively simple, but I can't find any notes anywhere for it. Can anyone help me out with the code that needs to be added to the client and the host so the host can send messages back to the clients? Thanks!

Share this post


Link to post
Share on other sites

Using the standard recvfrom , in Win32 or sockets using Linux headers, you can easily return messages to the person who sent them. The Recvfrom function has an argument which takes by reference a sockaddr pointer which it populates with the information of the person who sent the packet. You can use that in the sendto function to return a message. However, I do not know the answer with SDL I am afraid :(.

Share this post


Link to post
Share on other sites

Thanks! It is the same thing in general. It is simply a matter of storing the sockaddr information and updating it for sendto, the SDL_net version. Thanks!

Share this post


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