>>> From: Peter Scott [mailto:[EMAIL PROTECTED] >>> Subject: Re: Reading from multiple sockets. > >> On Tue, 21 Oct 2008 12:53:53 +0200, Kammen van, Marco, Springer SBM NL >> wrote: >> I'm pretty new to working with sockets in perl, looked around for days >> for a proper solution for my IRC/DCC problem but couldn't find one.
>>>Yeah I was planning to add another Perl programming book to my list.... >>>Thanks for all hints so far... I've got the following to work now using >>>IO::Select >>>Properly send & receive to and from server. >>>I can esablish a DCC connection over additional socket, but then I only >>>get the data from the DCC socket, and no-longer the data from the server >>>socket, untill the DCC socket is closed..... >>Never mind... I think i fixed it.... >>Dunno if its the proper way but hey it works!!!!!!!!! >>$con = IO::Socket::INET->new(PeerAddr=>"$server", >> PeerPort=>"$port", >> Proto=>'tcp', >> Timeout=>'30') || print "Error! $!\n"; >>$select = IO::Select->new(); >>$select->add($con); >>while(@ready = $select->can_write) { >> for $socket (@ready) { >> #The DCC Connection >> if($socket == $dcc) { >> $talk = <$dcc>; >> print $talk; >> #The Server Connection >> } elsif ($socket == $con) { >> $answer = <$con>; >> print $answer; >> # Stufff >> if ($answer =~ /:(.*)\!.* PRIVMSG $me :\001DCC CHAT chat (\d+) ( >>+\d+)\001\r\n/) { >> print "Received dcc from $1 with $2 and $3\n"; >> $dcc = IO::Socket::INET->new(PeerAddr=>"$2", >> PeerPort=>"$3", >> Proto=>'tcp', >> Timeout=>'30') || print "Error! >>+ $!\n"; >> print $dcc "Please Enter Your Password!\n"; >> $select->add($dcc); >> } >> } else { >> print "Dunno?\n"; >> exit 1; >> } >> } >>} It looked like it worked but keep ending up in some kind of lock.... As soon as the second socket kicks in things go wrong.... It's a shame there are tons of pieces of code for IRC thingies, but none of a fully functional one including DCC connections.... (without using additional modules). Any help in the right direction is appreciated... (and yes I'm still waiting on my Perl networking book!) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/