Perl threads and UNIX sockets

Sebastian Weber webersebastian@yahoo.de
Sun Jan 28 19:40:00 GMT 2007


Hi all,

I found a problem in the current cygwin perl (v5.8.7 built for 
cygwin-thread-multi-64int): The following code sets up a UNIX domain 
socket server and connects to that server in a different thread. It will 
block forever exactly at the connect / accept calls:

#!/usr/bin/perl
use threads;
use Socket;

unlink ("/tmp/mysock");
$t=threads->create("con_thread");

socket (SOCK1,PF_UNIX,SOCK_STREAM,0) or die "socket(): $!";
bind (SOCK1, sockaddr_un("/tmp/mysock")) or die "bind(): $!";
listen(SOCK1,SOMAXCONN) or die "listen(): $!";
accept (CLIENT,SOCK1);
$t->join();

sub con_thread {
    sleep(2);
    socket(SOCK2, PF_UNIX, SOCK_STREAM, 0) or die "socket(): $!";
    connect(SOCK2, sockaddr_un("/tmp/mysock")) or die "connect(): $!";
}

This code will _not_ block using perl v5.8.7 on Linux or HPUX. Is this a 
bug? Is there a workaround?

Greets, Sebastian


		
___________________________________________________________ 
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list