Re: Sending and Receiving over socket



On Apr 14, 9:12 pm, "Jack" <accpac...@xxxxxxxxxxx> wrote:
Hi Everyone,
I have a question. If I have a client and a server machine and on my
client machine I execute this code:

send (socketfd, &rHeader, 2 * sizeof(int)), 0);

and on my server machine I execute:

recv (socketfd, &buffer, 2 * sizeof*(int)), 0);

can I be sure that the full buffer will be sent and received when
these two are executed.

Yes and no.

The send() will schedule transmission of the data you've provided. It
is up to the sockets, tcp/ip and ethernet/ppp layers to determine
whether the data will consist of one packet or multiple packets, and
schedule the transmission of the packets.

On the recv() side, recv() will only return the data that has been
received and dequeued. This /may/ be less than the amount you sent.
You will have to recv() until you have received all the data.

If not is there a way to make sure that these two I done.

On the sending side, you can close the tcp connection (assuming a
stream socket). This will force the scheduling (in due time) of the
transmission of the remaining data. However, as you will have closed
the connection, you won't be able to send any more data across that
connection. And, assuming that you did not perform a half-close, you
won't be able to receive any data at the sending side either.

I guess I am looking for a function like fflush() but for sockets.

AFAIK, there aint no such thing

HTH
--
Lew



Thanks


.



Relevant Pages

  • Re: Xming usage
    ... Depends on the speeds of the X client machine, the X server machine, ... using gimp to edit a huge image, ... or connection) a little harder than it can easily cope with. ...
    (Debian-User)
  • Re: Sending and Receiving over socket
    ... If I have a client and a server machine and on my ... client machine I execute this code: ... You seem to be missing the basics about TCP. ...
    (comp.unix.programmer)
  • Sending and Receiving over socket
    ... If I have a client and a server machine and on my ... client machine I execute this code: ... sockets. ...
    (comp.unix.programmer)
  • Sending and Receiving over socket
    ... If I have a client and a server machine and on my ... client machine I execute this code: ... sockets. ...
    (comp.unix.programmer)
  • problem running MS SQL Web Data Admin
    ... My client machine is XP Pro with SP1 with IIS 5.1 My server machine is ... in mixed mode) as well as MS SQL Web Data Admin (webadmin) installed on it. ... I then installed webadmin on the Client machine but can't get it to connect ... Exception Details: System.Runtime.InteropServices.COMException: COM object ...
    (microsoft.public.sqlserver.msde)