Networking Forums

Networking Forums > Computer Networking > Linux Networking > A tcp connetion question

Reply
Thread Tools Display Modes

A tcp connetion question

 
 
Jimmy
Guest
Posts: n/a

 
      06-27-2007, 11:10 AM
They r two processes, for client and server, connected with TCP. Connection
is OK.
I killed the server process, while the client seems not to feel that before
it sent some data by calling send().
And it checked the errno, which indicated a segmentation fault error.

Why should it be segmentation fault rather than something indicating
disconnection?



 
Reply With Quote
 
 
 
 
Jimmy
Guest
Posts: n/a

 
      06-27-2007, 11:51 AM
Sorry, I realize the segmentation fault was caused by perror(). After
calling send(), the value of errno is 29, which caused perror() to crash
whole process. Confused...

However, that ain't problem. I just wanna know how to make client process
detect such situations as server killed, network
cable unplugged or anything else that can cause the disconnection?


 
Reply With Quote
 
Robert Harris
Guest
Posts: n/a

 
      06-27-2007, 05:02 PM
Jimmy wrote:
> Sorry, I realize the segmentation fault was caused by perror(). After
> calling send(), the value of errno is 29, which caused perror() to crash
> whole process. Confused...
>
> However, that ain't problem. I just wanna know how to make client process
> detect such situations as server killed, network
> cable unplugged or anything else that can cause the disconnection?
>
>


Your segmentation fault indicates a bug in your program. perror()
doesn't normally crash even if the value of errno is 29 - you have tried
to write to some area that doesn't belong to you. Running the process
under gdb should tell you what caused the crash.

You detect such situations when recv() returns 0 (for an orderly
shutdown) or -1 (for an error).

Robert
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tool to monitor PtP connetion continuously MSNews Windows Networking 1 10-13-2009 06:41 PM
wireless laptop losees connetion ro router sean mccoy Network Routers 4 02-01-2006 08:41 AM
2 routers 1 connetion problem Bob Bedford Network Routers 0 09-20-2005 04:54 PM
Sharing Cable Connetion Through another computer Beth Broadband Hardware 4 10-17-2004 02:58 AM
Read signal strength of network connetion Jürgen Wagner Wireless Networks 1 08-16-2004 09:58 PM



1 2 3 4 5 6 7 8 9 10 11