Send/Receive

This is a discussion on Send/Receive within the Networking/Device Communication forums, part of the General Programming Boards category; I would like to hear some opinions on how you should make sure your Client-Server commnunication will work properly. More ...

  1. #1
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853

    Send/Receive

    I would like to hear some opinions on how you should make sure your Client-Server commnunication will work properly.

    More in details, I am making a turned-based game. So what happens is that when you make a move an array of strings is updated with the specific string command. Then when your turn ends, I send all the strings through a network stream on a TCP/IP connection.

    I want to use (for now) a synchronized/blocking Send()/Receive() method. Using .NET library. My question is, what measures do I have to take?

    The data I am sending is small. Meaning that it should fit in one package. Do I have to make a confirmation method, like sending back an "Received" message? Or is this done anyway by the TCP/IP protocol for each package?
    Will using one Send() method be better (one for the array of strings) or using one Send() for each string in the array? I would guess same thing...

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,262
    If you are using TCP (which you should be), then the acknowledgements and packet level details will happen behind the scenes. All you need to do is call Send and Receive for the data you care about.

    Keep in mind that if you send 1000 bytes on one side, and you attempt to receive 1000 bytes on the other side, there is no guarantee that you will receive all 1000 bytes. It make take 2 or more calls to Receive() to receive all the data. Also, if you call Send twice sending 1000 bytes each time, the receive side may get 2000 bytes with the first call to Receive().
    bit∙hub [bit-huhb] n. A source and destination for information.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. send/receive udp from specific NIC
    By dsollen in forum Networking/Device Communication
    Replies: 2
    Last Post: 10-27-2009, 05:55 PM
  2. Sockets: send/receive continuous stream of data?
    By diddy02 in forum Networking/Device Communication
    Replies: 1
    Last Post: 08-09-2008, 01:52 AM
  3. Send/receive at the same time problem
    By nlight in forum C Programming
    Replies: 3
    Last Post: 05-12-2005, 07:06 PM
  4. simple serial send/receive problem
    By gMan in forum C Programming
    Replies: 4
    Last Post: 04-02-2003, 05:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21