Help Needed: One "recv()" contains data sent by many "send()" ...

Discussion in 'Windows Networking' started by Shashank Welankar, May 18, 2004.

  1. Sub: Help Needed: One "recv()" contains data sent by many "send()" ...

    I have a Server Application, as usual listening on certain port and
    accepting connections. It recvand send data between clients. I have a fixed
    format of sending messages from clients. All clients send data enclosed
    in*[ and ]* character sequence, eg: suppose the data from client A is this -
    *[Hello, How are you? Sending filename in next message]*
    then next message will be-

    Now, this works fine. But when any client start sending data too rapidly,
    then it often become possible that 2 messages clubbed into one recv(), for
    example, On executing recv() with a buffer of size > 512 bytes, the buffer
    possible might contain this:
    *[Hello, How are you? Sending filename in next

    Only one recv now contain both the messages. In this situation, I need to
    parse data and separate the messages manually by string processing. But
    possible many times more messages behind these messages. And usually the
    last messages is Incomplete.

    My concern is this Incomplete message, in my application these Incomplete
    messages are usless. So I must eleminate them. I can see 2 options to solve,
    this problem:
    a) Either I receive one message at a time from WinSock Layer, (ie One
    recv() call must return one message).
    b) OR the Last message must be complete, if there is space but not as
    much that can hold next message, then this left space must not be used.

    Am I right, any other Solution some one can suggest.
    Also, please suggest a way, using which atleast one of the option a -or- b,
    can be achieved.


    -Vipul Pathak ;
    Shashank Welankar, May 18, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.