Thread: Client accidently close when the server crash

  1. #1
    Registered User
    Join Date
    Dec 2010
    Posts
    13

    Client accidently close when the server crash

    The steps to test the problem
    1. Open TCP Server
    2. Open TCP Client
    3. TCP Client sends data to Server.
    4. Close TCP Server and the client also crash without any notification

    Second wonderful test:
    1. Comment the following statement in Client.c (at line 168) and compile it
    Code:
    Writen( sockfd, data.send_buf, strlen( data.send_buf ), __FILE__, __LINE__ );
    2. Run TCP Server
    3. Run TCP Client (since no writen(), so response from server, it is OK)
    4. Close TCP Server
    5. A lot of rubbish from TCP Server.........




    I also posted the source code here.
    Compile TCP Server
    Code:
    gcc -Wall -lmcheck -g -Werror -lpthread -o server server.c
    Compile TCP Client
    Code:
    gcc -Wall -lmcheck -g -Werror -lpthread -o client Client.c lib/*.c
    I can't upload a zip file, so I upload the source code to the web
    http://ericc.member.lostcity-studio.com/SourceCode.zip

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,667
    Perhaps you could start with the debugger, as in

    gdb ./server

    When you're ready to run it, just type 'run'

    When it crashes, start with the 'bt' command to show the stack trace to the crash location. Identify the most recently called function in your code, and start looking around. Starting with bad pointers.

    GDB has a 500+ page manual - it can do a lot of things for you.
    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.

  3. #3
    Registered User
    Join Date
    Dec 2010
    Posts
    13
    Quote Originally Posted by Salem View Post
    Perhaps you could start with the debugger, as in

    gdb ./server

    When you're ready to run it, just type 'run'

    When it crashes, start with the 'bt' command to show the stack trace to the crash location. Identify the most recently called function in your code, and start looking around. Starting with bad pointers.

    GDB has a 500+ page manual - it can do a lot of things for you.

    Thank you. I try it now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Client/server problem; server either stops receiving data or client stops sending
    By robot-ic in forum Networking/Device Communication
    Replies: 10
    Last Post: 02-16-2009, 11:45 AM
  2. how we can get client id in server
    By cnu_sree in forum Networking/Device Communication
    Replies: 1
    Last Post: 09-04-2006, 05:14 AM
  3. Client-server on a LAN
    By Niara in forum Networking/Device Communication
    Replies: 3
    Last Post: 02-15-2006, 05:44 AM
  4. Close - But a Crash
    By smitsky in forum C++ Programming
    Replies: 3
    Last Post: 12-15-2004, 05:51 AM
  5. client / server
    By PutoAmo in forum C Programming
    Replies: 4
    Last Post: 05-24-2002, 05:09 PM