Just another Perl shrine | |
PerlMonks |
Socket programmingby Anonymous Monk |
on Oct 06, 2000 at 13:39 UTC ( [id://35554]=perlquestion: print w/replies, xml ) | Need Help?? |
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Trying to code the following:
One program is the main program, which fork/execs one referee process and two player processes. It then waits until all three terminate. It should check that the command line parameter specifies the number of games is legal and pass it to the referee process as a parameter to exec(). One program is a referee program, which playes the role of a server. This program should prepare a socket and then listen to both players to send the string ``READY'', which means that they're ready to make a choice. It should then tell each player to make a choice by sending them both the string ``GO''. Their responses are then read, and their scores are calculated and updated. This process should be repeated until all of the turns have been taken, at which point the referee should send both players the string ``STOP'', which causes them to terminate. One program is a a player program, which playes the role of the client. This program is executed twice by the main program, and should start by connecting to the referee's socket. It should then send the ``READY'' message. When it receives the ``GO'' message back from the referee, it should make a choice anbd send it as a stringto the referee. When it receives the string ``STOP'', it should kill itself. Here's what I have so far: Here's the main program "play": Here's the referee "server": Here's the player "client": My problem is in getting the server program to communicate with the client. Here's what I know: When I run "play", the server receives the 2 "READY" signals from the clients and the following code line DOES get executed: However, the if (/GO/i) conditional in the client program is not getting executed and I do not know why. Is it something simple or is bi-directional communication really harder than I originally thought? My only guess is that somehow I'm not sending the "GO" message properly. I just don't understand why the server was able to receive the "READY" with no problem, but the client is choking on the "GO". Any help would be much appreciated. Magius_AR
Back to
Seekers of Perl Wisdom
|
|