Thread: Networking Help

  1. #1
    Registered User
    Join Date
    Jun 2010

    Networking Help

    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 and here is an example of what the data generator is sending (not sure if it's relevant, but whatevs):
    00000000001-0101010101010101010|2010-06-16 10:56:07.030374|1234567891234567891|1|1234567891234567891\n
    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:

    Thanks, and if you need any more info from me please let me know

  2. #2
    Registered User
    Join Date
    Jun 2010

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    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.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need Homework (Multi-threading & Networking)
    By Kurisu33 in forum C++ Programming
    Replies: 4
    Last Post: 12-23-2006, 06:00 PM
  2. networking comfirmation
    By rEtard in forum Networking/Device Communication
    Replies: 1
    Last Post: 07-20-2005, 03:59 PM
  3. Networking question.
    By MethodMan in forum Tech Board
    Replies: 9
    Last Post: 09-03-2002, 10:50 AM
  4. Beyond MFC : COM || Networking
    By kuphryn in forum Windows Programming
    Replies: 5
    Last Post: 04-25-2002, 04:28 PM
  5. C++: Reference Book, GUI, Networking & Beyond
    By kuphryn in forum C++ Programming
    Replies: 4
    Last Post: 11-10-2001, 08:03 PM