As for buff2 containing AB if the recv failed (as indicated by -1) the contant of buff2 is left as is (garbaged)
I don’t see why in your code the second recv failed. However NEVER expect recv to be of same size as send, TCP/IP is a STREAMING protocol and not a PACKET protocol.
If send or recv return -1 you should check errno for more clue as to what is going on.
I had tried that before, but as you had mentioned i re-tried that. It still gives me the same problem.
But I also realised a stange behavior … if my second send has 1460 as the sizefield … i can recived it at the server side. I knew this but didnt put it in the first post as I thought i was doing something wrong.
send(sd, ch, sizeof ( ch ), 0);
send(sd, ch2, 1460, 0); //basically more than 1460
So it does transfer the second send() only when the size is more than 1460 on client side. I did not change anything on the server side. This is weird ???