sockets - How to read on local port repeatedly using php? -
I have searched a lot on this subject and have tried a lot of things, but still I got stuck.
I have an EC2 example on which another example 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)); Go out; } $ Result = socket_bind ($ socket, $ host, $ port); $ Result = socket_listen ($ socket, 3); $ Spawn = socket_accept ($ socket); $ Input = socket_read ($ spawn, 84); $ Input; Socket_close ($ eggs); Socket_close ($ socket); Sometimes it runs, sometimes it does not happen, it returns an error on socket_bind (): "socket_bind (): addresses Unable to bind [98]: The address is already in use. "
I'v has seen a lot on this but nothing has worked ...
If someone comes up with something .. plz help ..!
thanx mayur
Comments
Post a Comment