Jump to content

  • Log In with Google      Sign In   
  • Create Account

SDL Net - Receiving and sending on same TCP connection ?


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
3 replies to this topic

#1 ElCommunist   Members   -  Reputation: 107

Like
0Likes
Like

Posted 12 October 2013 - 05:44 AM

Hello everyone, and thanks for your valuable time smile.png

 

I am working on the networking part of a game, using SDL_Net as Networking library.

I tried the tutorial about SDL_Net TCP basics, and everything worked fine (server listening, client sending)

 

But now, I don't really know how to design the communication in both directions :

I would like to create one thread listening via the server TCP socket, and another thread sending via the same socket, at the same time (so this is the same TCP connection used for both sending and receiving, potentially simultaneously))

-> Is it safe ? performant ?

-> Or do I need to create one TCP connection for sending messages on one thread, and another TCP connection for listening on another thread ?

 

I know that some TCP connection are duplex which enable what I want, but I don't know about SDL Net...

 

Again, thanks for your help smile.png


Edited by ElCommunist, 12 October 2013 - 09:37 AM.


Sponsor:

#2 3TATUK2   Members   -  Reputation: 730

Like
0Likes
Like

Posted 12 October 2013 - 02:38 PM

I don't think you should really have to worry about splitting send/receive into separate threads. Just do them "procedurally"/"immediately" ... internally they will get queued in the appropriate manner to be handled



#3 hplus0603   Moderators   -  Reputation: 5725

Like
0Likes
Like

Posted 12 October 2013 - 09:06 PM

WinSock 1.x didn't support simultaneous send/receive on sockets. WinSock 2.2, which is what everyone should have been using for the last 20 years or so, does support that. Linux has always supported that AFAIK.

Note that "TCP connection" and "socket" are slightly different concepts -- you're really asking about sockets here.


enum Bool { True, False, FileNotFound };

#4 ElCommunist   Members   -  Reputation: 107

Like
0Likes
Like

Posted 15 October 2013 - 02:30 PM

Thanks for your answers :-)

 

Finally I will go with 3STATUK2 idea (synchronous way) and look at game loop performance. I will try later to go asynchronously and compare the two.






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