c - recv()/read() in client never terminates -
i'm trying implement client receives , sends data from/to server. however, while sending works, receive never , program hangs there.
this bare bones problem area without error checking.
//send data char* message = "list\n"; write(sockfd, message, 5); //receive data int numbytes; char buf[100]; if ((numbytes = recv(sockfd, buf, 99, 0)) == -1) { perror("recv"); exit(1); } buf[numbytes] = '\0';
i tried insanely basic-
//send data char* message = "list\n"; write(sockfd, message, 5); //receive data char* buf = calloc(1, 100); read(sockfd, buf, 7); //the message i'm supposed receive 7 bytes, tried 6 , 8 account nulls etc
this hangs @ read too.
edit: terminates after added
shutdown(sockfd, 1);
after send data part, while response should
ok\n7 try.txt
the response
ok
Comments
Post a Comment