LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-06-2005, 07:38 AM   #1
arunka
Member
 
Registered: Mar 2005
Posts: 60

Rep: Reputation: 15
socket programming problem...???


hi all

i have written a client / server program,
In the server i am waiting for a connection and after accepting the connection from a remote client i am sleeping for 5 sec, wiyhin this interval
i have unplugged the network cable ...
After the sleep is over i sent some data using send.
The perror after send is giving succes.
(Remember i have unplugged the cable...!!!)
i want to know a mechanism from which i should know before sending only whether the cable is plugged in or not..???

Thanks in advance...

-Arun KA
 
Old 10-06-2005, 12:09 PM   #2
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
You need to use a TCP socket, rather than a UDP socket.

With UDP, no acknowledgement is sent for packets and no error correction is done; this makes the transport very fast but not very reliable. With TCP, everything is acknowledged and checksums exchanged; this can lead to lag when communicating over lossy connectors, but ensures that everything that is sent is actually received (or the connection dropped).
 
Old 10-10-2005, 07:13 AM   #3
arunka
Member
 
Registered: Mar 2005
Posts: 60

Original Poster
Rep: Reputation: 15
i am using TCP sockets only. but still the problem is same.
 
Old 10-10-2005, 06:45 PM   #4
AlonsoTheBonzo
LQ Newbie
 
Registered: Jul 2004
Distribution: whatever
Posts: 10

Rep: Reputation: 0
Not sure, but im guessing it has something to do with the fact that you are writing to a valid file descriptor (the socket) and nothing is actually physically sent until the buffer is flushed / closed. Perhaps you could try a flush before the send? Interesting problem - if you find an answer please post it.
 
Old 10-11-2005, 08:08 AM   #5
greghua
LQ Newbie
 
Registered: Apr 2005
Posts: 19

Rep: Reputation: 0
Re: socket programming problem...???

Did you use the "stay alive" option. I think the possible reason is the period that you unlpuged the cable is too short. The protocol usually waits a pretty long time before it break the connect. You can check Steve's "Unix Network programming" for more details.


Quote:
Originally posted by arunka
hi all

i have written a client / server program,
In the server i am waiting for a connection and after accepting the connection from a remote client i am sleeping for 5 sec, wiyhin this interval
i have unplugged the network cable ...
After the sleep is over i sent some data using send.
The perror after send is giving succes.
(Remember i have unplugged the cable...!!!)
i want to know a mechanism from which i should know before sending only whether the cable is plugged in or not..???

Thanks in advance...

-Arun KA
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
pthread socket programming problem hk_michael Programming 1 04-03-2005 08:54 PM
Socket programming maldini1010 Programming 4 02-11-2005 11:16 PM
Socket Programming Chaitanyayardi Programming 6 10-22-2004 12:10 AM
socket programming problem bgraur Programming 2 03-09-2003 09:05 AM
Socket programming problem krivi Programming 3 01-14-2002 02:04 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration