i've already read these topics and still hasnt find the answer
| [reply] |
Its a complex interaction to have multi-threaded client talking in a bidirectional manner to a mutithreaded server. To be honest, I've only seen 1 example of a multi-threaded server that worked, and that was with a forking client. You are jumping into very deep water, and you expect some simple looking scripts to have working complex functionality. I would suggest you study how the forking chat server-clients work first, before complicating it with threads. 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.
| [reply] |