Hi! I've been trying to learn socket programming, but have run into a problem. I copied one of the server examples from Beej's Guide to Network Programming and have been using a data generator a friend of mine made a while ago. It connects once, all the data goes through, but when it gets to the accept() call in the while loop again I get a segmentation fault.
Here is my code http://codeviewer.org/view/code:fed and here is an example of what the data generator is sending (not sure if it's relevant, but whatevs):
It is 101 characters long, sent in plaintext, including the newline at the end.
I ran it through gdb, just to try to figure stuff out and here is the output from that: http://codeviewer.org/view/code:fee
Thanks, and if you need any more info from me please let me know
What does your use of "continue" do in the child process?
A: resume a loop which is no longer valid.
The child reads the socket, closes the socket and then exits.
Oh, and numerous buffer overflows in the reader function as well. You can't fit X bytes into an X-byte buffer AND have it \0 terminated.