OK so I was writing a program that used the socks4 protocol, and I ran into something rather annoying. If I create a TCP socket, once the remote host closes it if I try to call write() on the socket it straight up terminates my process rather than giving an error. Paraphrased portion of code:
printf("Going to send new line...\n");
write(fd, "\n", 1);
printf("Sent new line.\n");
It would print the first message, but the program would terminate before the second line was printed. Is there something I'm missing, or is write() not acting like it's supposed to?
Bookmarks