Greetings oh wise ones. I'm working on a simple client/server script that just talks back and forth, but I'm having trouble with the script not processing my if statements after data is sent to it. I will then however continue on after more data is sent and stop again at the same place. The ####Problem here.#### is where the server stops after I send it the first bit of information. Here is the code minus some of the basic socket stuff which I omitted.
ServerClientwhile(1){ $MySocket->recv($text,2); if($text ne '') { print "\n Number'", $text,"'\n","\n"; ####Problem here.#### if($text=~m/\d.*/){ print "\nThat's a number"; }else{ print "\nNot a number"; } }else{ print "Cilent has exited!"; exit 1; } }
print "\n",$def_msg; while($msg=<STDIN>) { chomp $msg; if($msg ne '') { #print "\nSending message '",$msg,"'"; if($MySocket->send($msg)){ print ".....<done>","\n"; print $def_msg; } } else { # Send an empty message to server and exit $MySocket->send(''); exit 1; } }
After the server reads in the input it runs the print statement with the:
print "\n Number'", $text,"'\n","\n";But it won't run the if statement after it until I sent another piece of data from the client E.G. I fire open the client and type in the number 1 then hit enter. My server prints this output:
>> Server Program << Number'1'
And stops there until I enter something else on my client; say I enter the number 2. My server now looks like this:
So it moved on to the if statement only after seeing more input from the client. Any ideas?>> Server Program << Number'1' That's a number Number'2'
In reply to IO Socket INET stopping in middle of script by oosnoopy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |