-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sun, 08 Jun 2003 22:59:05 +0000 "Bryan K." <ef057@hotmail.com> wrote: >I am implementing a server-client tcp-ip application and I would like >to know some things. >a) When read(2) returns, is it sure that the other side has recieved >the whole buffer passed to read(2)? Maybe you wanted to say "When write(2) returns..."?! In this case the answer is NO since a successfull return from write(2) means you successfully wrote data on the socket descriptor. Application level is blind as regards this kind of problems since it doesn't know this data will be sent on a network. The other layers will take care of it. >b) If i have a loop which write(2) one byte at each itteration, the >kernel sends many tcp packets each one containing one byte of >userfull data? The answer is "it depends". If you are using an interactive application such as Telnet this is just the situation (even if the Nagle algorithm slightly modifies this scenario for obtaining better performances). In fact, if we suppose Nagle algorithm doesn't exist (or better if it was simply disabled), every character you type is sent as a single packet. On the contrary, you may force the opposite behaviour by setting TCP_CORK socket option telling the kernel not to send a packet until its length is equal to PMTU. >c) An ACK is sent when the kernel receives a tcp packet or when a >userspace read(2) from the socket occurs? The first one. When you have doubts about these situations you should always consider the TCP/IP stack layered structure. The application doesn't know what is an ACK since it is not involved in this kind of troubles. Moreover, how could an application send an ACK if the packet TCP header was removed before passing data payload to the same application? Acknowledging the reception of a chunk of data is done by TCP. Regards. - -- Angelo Dell'Aera 'buffer' Antifork Research, Inc. http://buffer.antifork.org PGP information in e-mail header -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQE+5RS2pONIzxnBXKIRArBsAKCtk37cF7DOkImuG3z0umrxHG1GrgCfXu4H 2I/wPJRlNhkyITlbOOuPYP0= =zce1 -----END PGP SIGNATURE----- -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/