I have a perl server side socket that returns fields one by one invoking send() on the client socket.
I have no issues in reading all the fields at the client side if the code is like below:
while ($response = <$sock>) {
print "$response";
last if $response eq "END_OF_REQUEST";
}
But if the client side code is like below, it's going into a loop and is not working:
while(1) {
$sock->recv($response, 1);
print "$response\n";
last if $response eq "END_OF_REQUEST" ;
}
I agree that i can club all the fields and invoke only one send at the server side. But i am interested in knowing what's wrong with the 2nd approach. Does changing the LENGTH arg of the recv in 2nd approach does the trick?
I kind of started getting hands-on directly without proper theoretical knowledge about sockets. Thanks for your patience.