[EMAIL PROTECTED] wrote:

> 
> Hello all,
> Any help on this question would be appreciated. I am a newbie to this
> site, so I have not figured my way around yet. Forgive me if this
> question is answered somewhere else.
>  
> My application runs on RH Linux. I have set of perl processes that are
> communicating through a UNIX socket.
> my $s = IO::Socket::UNIX->new(
> Type => SOCK_STREAM,
> Local => $sockname,
> Listen => 10,
> ReuseAddr => 1,
> );
> One of these processes goes away for an extended period of time and
> comes back eventually. During the time that it is gone it is not able to
> read from it's pipe. This is causing the other process that is writing
> to the pipe to wait for an extended period of time. When this happens,
> bad things occur in my application.
> One idea I would like to try is to set the socket's underlying recieve
> buffer to as large as possib! le.
> Questions:
> Can anyone tell me how to set the socket's underlying receive buffer size?
> What is the maximum size that the buffer can be?
> From reading the perldoc on IO::Socket it seems that I should be able to
> do the following to get the current receive buffer size:
> my $rcv_buf_size = $s->sockopt($SOCKET::SO_RCVBUF);
> But when I tried this $SOCKET::SO_RCVBUF is undefined. Am I doing
> something wrong?

Not sure.  I've tested in Win32 and this code works:

my $rlen = $s->getsockopt(SOL_SOCKET, SO_RCVBUF);
# rlen=8192
$rlen = $s->setsockopt(SOL_SOCKET, SO_RCVBUF, 32768);
# rlen=1 (good return)
$rlen = $s->getsockopt(SOL_SOCKET, SO_RCVBUF);
# rlen=32768

> It seems that the writing process gets stuck trying to write to this
> processes socket. How do I make the writer return immediately even if it
> cannot write all of the data?

You can always use IO::Select and do a can_write before writing.

You could also do non-blocking writes by setting TCP_NODELAY:
        $s->setsockopt(IPPROTO_TCP, TCP_NODELAY, 1);

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to