Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

send() was hold when sending message with Bolcking mode
Hi,

In my case, send() function is used for sending server message by client and
the socket's mode is Blocking. When the server broke down, the client still
sent message because it didn't know the server was down. After a while, the
send() was hold and couldn't be recovered.
When the socket uses blocking mode, how to recover the blocked send()?

Thanks,
Ethan



Report this thread to moderator Post Follow-up to this message
Old Post
Ethan Yu
12-09-04 09:02 PM


Re: send() was hold when sending message with Bolcking mode
In article <cp9oft$n0s$1@news.yaako.com>, "Ethan Yu" <ycy_76@163.net>
wrote:

> Hi,
>
> In my case, send() function is used for sending server message by client a
nd
> the socket's mode is Blocking. When the server broke down, the client stil
l
> sent message because it didn't know the server was down. After a while, th
e
> send() was hold and couldn't be recovered.
> When the socket uses blocking mode, how to recover the blocked send()?

You can use alarm() to send a signal if send() blocks for too long.  Or
use select() to check whether the socket is writable.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

Report this thread to moderator Post Follow-up to this message
Old Post
Barry Margolin
12-10-04 01:57 AM


Re: send() was hold when sending message with Bolcking mode
Barry, thanks! The client run based single thread, so the client will still
be blocked if I use alarm() to send a signal.
And in ethereal package, no signal was found when server broke down, I think
we can't get state of this connect.
"Barry Margolin" <barmar@alum.mit.edu> 写入消息新闻:barmar-2FB128.19305409122004@comcast.dc
a.giganews.com...
> In article <cp9oft$n0s$1@news.yaako.com>, "Ethan Yu" <ycy_76@163.net>
> wrote:
> 
>
> You can use alarm() to send a signal if send() blocks for too long.  Or
> use select() to check whether the socket is writable.
>
> --
> Barry Margolin, barmar@alum.mit.edu
> Arlington, MA
> *** PLEASE post questions in newsgroups, not directly to me ***



Report this thread to moderator Post Follow-up to this message
Old Post
Ethan Yu
12-13-04 09:08 PM


Re: send() was hold when sending message with Bolcking mode
In article <cpkbt3$99e$1@news.yaako.com>, "Ethan Yu" <ycy_76@163.net>
wrote:

> Barry, thanks! The client run based single thread, so the client will stil
l
> be blocked if I use alarm() to send a signal.

If the SIGALRM handler performs a longjmp(), the send() will be exited
as a result.  Or you can disable system call restarting for SIGALRM, so
send() will return -1 with errno set to EINTR.

> And in ethereal package, no signal was found when server broke down, I thi
nk
> we can't get state of this connect.

Signals are not something that shows up on the network, they're internal
to the Unix process.  Did you mean "no message was sent when server
broke down"?  That's true.  This is why you have to use some kind of
timeout in the application.

> "Barry Margolin" <barmar@alum.mit.edu>
> 写入消息新闻:barmar-2FB128.19305409122004@comcast.dca.giganews.com... 

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

Report this thread to moderator Post Follow-up to this message
Old Post
Barry Margolin
12-14-04 02:01 AM


Re: send() was hold when sending message with Bolcking mode
Barry, thanks! The client run based single thread, so the client will still
be blocked if I use alarm() to send a signal.
And in ethereal package, no signal was found when server broke down, I think
we can't get state of this connect.
"Barry Margolin" <barmar@alum.mit.edu> 写入消息新闻:barmar-2FB128.19305409122004@comcast.dc
a.giganews.com...
> In article <cp9oft$n0s$1@news.yaako.com>, "Ethan Yu" <ycy_76@163.net>
> wrote:
> 
>
> You can use alarm() to send a signal if send() blocks for too long.  Or
> use select() to check whether the socket is writable.
>
> --
> Barry Margolin, barmar@alum.mit.edu
> Arlington, MA
> *** PLEASE post questions in newsgroups, not directly to me ***



Report this thread to moderator Post Follow-up to this message
Old Post
Ethan Yu
12-15-04 08:58 PM


Re: send() was hold when sending message with Bolcking mode
"Barry Margolin" <barmar@alum.mit.edu> 写入消息新闻:barmar-E8FCD0.19414113122004@comcast.dc
a.giganews.com...
> In article <cpkbt3$99e$1@news.yaako.com>, "Ethan Yu" <ycy_76@163.net>
> wrote:
> 
>
> If the SIGALRM handler performs a longjmp(), the send() will be exited
> as a result.  Or you can disable system call restarting for SIGALRM, so
> send() will return -1 with errno set to EINTR.

Good idea! I'll try this solution.
Barry, thanks for your help!
 
>
> Signals are not something that shows up on the network, they're internal
> to the Unix process.  Did you mean "no message was sent when server
> broke down"?  That's true.  This is why you have to use some kind of
> timeout in the application.

Yes, the server broke down due to platform restarting, then no FIN, RESET or
other messages
were deliveried.
 
>
> --
> Barry Margolin, barmar@alum.mit.edu
> Arlington, MA
> *** PLEASE post questions in newsgroups, not directly to me ***



Report this thread to moderator Post Follow-up to this message
Old Post
Ethan Yu
12-15-04 08:58 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Unix Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:31 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.