Advertisement

UDP - Returning data.

Started by April 18, 2014 10:43 PM
1 comment, last by Tolito 10 years, 7 months ago

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!

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 :(.

Advertisement

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!

This topic is closed to new replies.

Advertisement