Thread: Client application having problem receiving from server side?

  1. #1
    Registered User
    Join Date
    May 2005

    Client application having problem receiving from server side?

    I have created a client server application using Winsock2.
    Now the problem is that data send by server is not fully received by client in one go. It is received in installments & also not correctly received.

    For example, the server application sends 293 bytes of data in a buffer of size 5000.
    Now the client receives the data in two installments: Ist--> 625 bytes & IInd--> 4375 bytes.

    Logically the first installment of 625 bytes must contain all the 293 bytes of data & second installment of 4375 bytes must be all 0's.

    But the problem is that the first installment contains all 0's & second installment contains 293 bytes of data.

    Why is this happening.

    Also how can i make sure that all the data send by server is received by the client in one go.

    Waiting for suggestions


  2. #2
    Registered User
    Join Date
    Nov 2002
    If the data is not coming over the wire correctly then you are not sending it correctly. Also you have a flaw in your thinking. You need to view the socket as a stream, not as the entire block of data. You handle it as it comes in, if that involves buffering it then so be it. But the data on the stream is going to be broken down into smaller portions and you'll only be able to receive what is there when you ask for it.

  3. #3
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    It would be useful to provide the source surrounding the server's send() and the client's recv(), but I will expand on what orbitz replied. You've stated that the server sends a buffer of 5000 bytes to the client and that the client is receiving the data in two "installments." If you know the server is sending 5000, your client should be receiving 5000. This is not required, but it's something to think about. Furthermore, you should understand that the client receives streams of bytes in the order they were sent, one byte at a time. Start from there, supply some source, and update us with your progress/discoveries.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. IPv6 multicast client fails to receive server response
    By perfect in forum Networking/Device Communication
    Replies: 10
    Last Post: 06-21-2009, 11:30 PM
  2. How to Send Mac Address From Client to Server
    By Lieyza197 in forum C Programming
    Replies: 2
    Last Post: 05-27-2009, 09:58 AM
  3. Multi-threaded UDP Server Problem
    By nkhambal in forum C Programming
    Replies: 0
    Last Post: 07-05-2005, 02:27 PM
  4. Run time error at client side query?
    By dp_76 in forum Networking/Device Communication
    Replies: 0
    Last Post: 07-01-2005, 03:02 AM
  5. [SOCKETS] Solaris server in C, NT client in VB
    By Daveg27 in forum C Programming
    Replies: 3
    Last Post: 05-23-2002, 10:02 AM