I have searched a lot on this topic and tried a lot of thingd but still i'm stuck.
I have an ec2 instance on which another instance is sending some data through tcp on a specific port. I am using the following code..
$host = "x.x.x.x";
$port = 2048;
$socket = socket_create(AF_INET, SOCK_STREAM, 0) ;
if (!socket_setopt($socket, SOL_SOCKET, SO_REUSEADDR, 1))
{
echo socket_strerror(socket_last_error($socket));
exit;
}
$result=socket_bind($socket, $host, $port);
$result = socket_listen($socket, 3);
$spawn = socket_accept($socket);
$input = socket_read($spawn, 84);
echo $input;
socket_close($spawn);
socket_close($socket);
Sometimes it runs , sometimes it doesn't , it gives error at socket_bind():
"socket_bind(): unable to bind address [98]: Address already in use"
I'v looked a lot on this but nothing has worked...
If someone comes upt with something.. plz help..!
thanx mayur