Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


UDP - Returning 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 Tolito   Members   -  Reputation: 256

Like
0Likes
Like

Posted 18 April 2014 - 04:43 PM

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!



Sponsor:

#2 PranavSathy   Members   -  Reputation: 122

Like
1Likes
Like

Posted 18 April 2014 - 05:55 PM

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



#3 Tolito   Members   -  Reputation: 256

Like
0Likes
Like

Posted 18 April 2014 - 09:54 PM

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!






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