Overview
Features
Download
Documentation
Community
Add-Ons & Services

Socket and Signal

Please post support and help requests here.

Socket and Signal

Postby cx500tc » 12 Dec 2007, 15:41

I noticed that a function such as Socket..receiveBytes will not return if it gets interrupted by a signal.

This is a problem for me as I do need to get out of the function upon receiving a signal. What is the Poco way of dealing with this case.

cx500tc
 
Posts: 26
Joined: 24 Sep 2007, 17:48

Re: Socket and Signal

Postby alex » 12 Dec 2007, 16:28

> I noticed that a function such as Socket..receiveBytes will not return if it gets interrupted by a signal.
>
> This is a problem for me as I do need to get out of the function upon receiving a signal. What is the Poco way of dealing with this case.

I'm not sure the issue of recv() not being interrupted by a signal has to do with Poco. You should check the documentation for your platform.

It may or may not work in your scenario, but the "Poco" way would be to avoid waiting indefinitely by using setReceiveTimeout() and/or avoid getting blocked by using poll(). Take a look at how poll() is used in receiveBytes() to prevent blocking for platforms with broken timeouts (HP-UX and Solaris).

HTH

Alex
alex
 
Posts: 1143
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Socket and Signal

Postby guenter » 13 Dec 2007, 16:16

Hmm, seems like a typical case of conflicting requirements for me:
http://sourceforge.net/tracker/index.php?func=detail&aid=1552787&group_id=132964&atid=725709

Stevens, in [[1] (which is the authoritave work on Unix TCP/IP programming) recommends handling EINTR in the way it is handled by POCO.

[[1] Stevens, W. Richard, UNIX Network Programming, Volume 1: Sockets and XTI, Prentice Hall, 1998
guenter
 
Posts: 1153
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: Socket and Signal

Postby cx500tc » 14 Dec 2007, 19:18

I disagree. If every blocking call would be protected against signals then what would be the use of CTRL-C...

It's up to the application to decide how to deal with this, not to a library such as Poco. If that was the case then the handling of the EINTR would have already been taken care of inside some POSIX functions such as recv... I wouldn't expect Socket.receiveBytes to be signal safe no more then I would using a stream for example.

Maybe the compromise would be to allow Socket to be or not be signal safe.
cx500tc
 
Posts: 26
Joined: 24 Sep 2007, 17:48

Re: Re: Socket and Signal

Postby alex » 15 Dec 2007, 12:35

> Maybe the compromise would be to allow Socket to be or not be signal safe.

I think this is a reasonable suggestion.

Alex
alex
 
Posts: 1143
Joined: 11 Jul 2006, 16:27
Location: United_States


Return to Support

Who is online

Users browsing this forum: No registered users and 3 guests

cron