I've just started a small sockets program. Basically, the client sends a string to the server. Upon receiving this string, the server sends another string to the client....
read(msgsd, buf, sizeof(buf) );
write(msgsd, "Hello from server", sizeof(buf));
write(sockfd, "Hello from client", sizeof(buf));
read(sockfd, buf, sizeof(buf));
When 'buf' is 100 bytes long, the messages get through without a problem. However, when I increase the size of 'buf' to 500 bytes, the client blocks on the read(). The situation used to be worse, I couldn't send messages larger than 50 bytes but after enabling the TCP_NODELAY option the situation has improved to where it is now. Could someone explain the logic behind this behaviour? I suspect that it might have something to do with the size of the I/O buffers for the socket but I'm not sure. Any feedb
ack would be much appreciated. Thanks in advance.