CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2009
    Location
    Lahore, Pakistan.
    Posts
    10

    send() and recv() parameters confusion

    On server Side:
    int recv (Socket,Buffer, Length, Flags)
    On Client Side:
    int send (Socket,Message, Length, Flags)


    can anyone plz tell me weather the 1st parameter in both of above is the same thing or not??
    if no .... plz tell me how to know that both the above commands are sending/receiving from same socket.

  2. #2
    Join Date
    Oct 2009
    Location
    Lahore, Pakistan.
    Posts
    10

    Re: send() and recv() parameters confusion

    send( socket , , ,0);

    recv( socket , , ,0);


    if one of them is on client side and the other is on server side .... and on both side integer socket that I pass to these functions has same value ... can I say that this recv() is for respective send()

  3. #3
    Join Date
    Feb 2005
    Posts
    2,160

    Re: send() and recv() parameters confusion

    I'm not sure I understand your second question, but as to your first question, both send and recv are designed to handle any arbitrary bitstream. The Length parameter tells each how many bytes to send or to expect to be received. The return values of both send and recv should be checked to ensure that the entire amount has been sent/received and if not, should loop until it is. It is up to the programmer to ensure that the stream is correctly parsed/cast on each end of the transaction.

  4. #4
    Join Date
    May 2001
    Location
    Germany
    Posts
    1,158

    Re: send() and recv() parameters confusion

    A socket connection is described by the 5-tupel (local IP address, local port, remote IP address, remote port, protocol).
    So the server and client both have the same values to describe the connection, but in different order (wrt local/remote).
    The "socket" itself is a resource descriptor, and its value can be anything meaningful to the underlying OS.

    HTH,
    Richard

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured