in reply to Re^2: chat between client and server
in thread chat between client and server
My first guess is that you need some IO::Select stuff in the threads.
My second guess is that you create your threads after you create your IO::Socket object, so both threads get their own copy of the object. That probably raises havoc. I would try to create the threads before you make the IO::Socket, then share the socket filehandle with the threads thru a shared variable. Then you can have some IO::Select loop in the threads to detect when they are in a recv or send mode. You can't read when the socket is in send mode, and vice-versa.....thats called blocking.
I don't want to discourage you from trying to figure this all out, but no one has done it before, and its for a reason. That reason is it involves alot of complex juggling of the socket filehandle, which you just sort of ignore with your simple code.
|
|---|