From: Kammen van, Marco, Springer SBM NL
>>Hi All!
>>
>>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.
>>
>>The connection to the server uses a socket with a neverending while
>>loop: 
> 
>>All works fine untill i want to make a DCC connection using another
>>socket: 
> 
>>The first loop is being blocked? 
>>I only receive input/output from the second loop untill this one is
>>closed again, then the first loop continues....
>>How can i get a continuous flow from both?
>>I've read some bits about IO::Socket::Select, and have also been
>playing
>>with multiple threads, but i prefer the first option... Any help is
>very
>>appreciated!

>>>You need to use select, or put a timeout on can_read on both sockets.

>>>See the following for how to use timeouts:
>>>http://perlmonks.org?node_id=716603
> 
>>>http://perlmonks.org?node_id=602621
> 
>>>zentara
> 
> Thanks for your input....
> The whole select thingie is still a bit blurry to me...(I really need
a
> Book). 
> 
> Which I forgot to mention is that both my sockets are connected to
> different ports... (54321 & 1024)
> And also, one socket is connected to a server, and the other socket is
> accepting from a client.... 
> Does this change anything??
> 
> So Loop 1 is reading stuff that is happening on the server.
> And Loop 2 is reading stuff that a direct client is sending.
> 
> Marco!


At this level, the only difference between a client and a server is the
opening sequence. After the sockets are open, they can be treated
exactly the same.

So once you have the sockets open, and as long as there are no pending
listens for additional connections, there are no differences in how you
read or write on multiple sockets. You need a single loop where select
will return when one or both sockets have received data, when it times
out or when a signal is received, whichever comes first. The timeout can
be used to check for other events, like keyboard input, before you loop
back into the select call.

Bob McConnell

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to