[LIP] Asynchronous IO on Linux
Gaurav Varshney <gkvarshney-/[email protected]>
| Newsgroups | gmane.user-groups.linux.india.programmers |
|---|---|
| Message-ID | <[email protected]> |
I am facing some problem while porting a program on
Linux. Just wondering if you can help..
I am having asynchronous IO b/w 2 processes through
socket. To implement AIO, I am using SIGIO. Following
approach works fine on solaris but not on linux. Is
there something wrong? Is there any change for SIGIO
on Linux ?
Client code (simplistic view):
# -- Start ------------------------------------------
setSigHandler();
while (1)
{
$last = DoProcessing();
last if ($last);
}
sub setSigHandler {
my ($socket) = $sock->{'SOCKET'};
fcntl($socket, F_SETOWN(), $$);
fcntl($socket, F_SETFL(), 4096);
$SIG{IO} = \&sigIO;
$SIG{POLL} = \&sigIO;
}
sub sigIO {
my ($socket) = $sock->{'SOCKET'};
my ($rin, $win, $ein, $rout, $numReady );
$rin = $win = $ein = '';
vec ($rin, fileno($socket), 1) = 1;
$numReady = select ( $rout=$rin, undef, undef, 0 );
error () unless ($numReady);
$sock->GetSockReply(); # Read data from socket
$SIG{IO} = \&sigIO;
return 1;
}
thanks,
Gaurav
=====
Cheers,
Gaurav Varshney
__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click