writing a client to a socket
Posted: Sat Jan 03, 2009 12:22 am
Hello,
I have a TCP server which runs on a certain port number.
Its a test type of server which just returns the what is sent from the client.
I want to write a client to the same program. I have the following code.
That doesnt seem to work or get the information that is returned from the server. Can this problem be solved?
What is wrong with this code? Please help me out
I have a TCP server which runs on a certain port number.
Its a test type of server which just returns the what is sent from the client.
I want to write a client to the same program. I have the following code.
Code: Select all
$message = "hello all ";//$argv[1];
$remote_socket = "192.168.1.103:7976";
$stream = stream_socket_client($remote_socket,$errno,$errstr,30);
if(!$stream)
{
//echo " $errstr ($errorno)";
echo "The message could not be sent to the server.. Internal server problem\n".$errstr." ".$errorno;
}
else
{
fwrite($stream,$message );
while(!feof($stream))
{
echo fgets($stream, 1024);
}
}
fclose($stream);
What is wrong with this code? Please help me out