Like Tree1Likes
  • 1 Post By Salem

Client accidently close when the server crash

This is a discussion on Client accidently close when the server crash within the C Programming forums, part of the General Programming Boards category; The steps to test the problem 1. Open TCP Server 2. Open TCP Client 3. TCP Client sends data to ...

  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
    32,834
    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.
    rags_to_riches likes this.
    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.

  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, 06: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, 06:09 PM

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