Networking Help

This is a discussion on Networking Help within the Networking/Device Communication forums, part of the General Programming Boards category; Hi! I've been trying to learn socket programming, but have run into a problem. I copied one of the server ...

  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    2

    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 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):
    Code:
    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: http://codeviewer.org/view/code:fee

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

  2. #2
    Registered User
    Join Date
    Jun 2010
    Posts
    2
    Help!

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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, 05: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, 07:03 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21