P is for Practical | |
PerlMonks |
perl networking problem,no threads usedby spx2 (Deacon) |
on Jan 11, 2007 at 09:27 UTC ( [id://594088]=perlquestion: print w/replies, xml ) | Need Help?? |
spx2 has asked for the wisdom of the Perl Monks concerning the following question:
i've read this http://www.perlfect.com/articles/sockets.shtml and found it to be a very good introduction to network programming in perl but my problem is that what is there is not enough. as one can see,it only permits communication in one sense and not the other. i've tried to improvise on what i saw there and try to make it the other way around also. i've succeded somehow,but it works only for...about 3 seconds and then i think it stops. i need help on this,i must say that i have checked a book Network Programming in Perl and also some other articles and was not able to found a solution. Ok,now the code,and afterwards some comments about it. receiver.pl
caller.pl
in caller.pl we have the first while wich is waiting for receiver to create the socket,and when the socket will be created !$sock will be true thus,it will exit the loop and start writing to the socket and reading from it. what it will do ,actually is,it will first write a message to the receiver,and then write a message that the receiver will interpret as to stop reading and do something else(receiver will write to the socket his message). and so forth,and in the end close the socket. in receiver.pl we create the socket and we start writing and reading from it,writing some messages to caller and reading what caller has said, but also interpret the "stop reading receiver!\n" message wich will mean the receiver will stop reading and will start writing some messages to caller,but in turn he will also issue a message to caller for him to stop reading ,the message for this will be "stop reading caller!\n". what i want you to know is that i do not intend to say that this code is very correct or anything ,i just want to make it work properly ,that is all. if you know of any other methods,please inform me. thank you
Back to
Seekers of Perl Wisdom
|
|