I get something very weird. I do on the server some write() in a loop.... and when i read() in the client I get a single buffer with all the things I have send from the server. Is this posible?
I get something very weird. I do on the server some write() in a loop.... and when i read() in the client I get a single buffer with all the things I have send from the server. Is this posible?
Yes.
TCP only guarantees that the order of bytes is preserved. During transmission, packets can be combined and fragmented. You need to be aware of this when sending and receiving.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
another problem is when I connect as a client to a server:
if i do this it timeouts on the connect() call;Code:temp.sin_family=AF_INET; temp.sin_addr.s_addr=htonl("127.0.0.1"); temp.sin_port=htons(111);
this works just fine.Code:struct hostent *ip; ip=gethostbyname("127.0.0.1") temp.sin_family=AF_INET; memcpy((char *)&temp.sin_addr.s_addr,(char *)ip->h_addr,ip->h_length); temp.sin_port=htons(111);
sorry... you are right... it doesn't compile without inet_addr()... in the actual program I used inet_addr() the post is a manual edit.
very sorry about this... i'm new to socket programming