Reusable socket

Posted by Andrew on Stack Overflow See other posts from Stack Overflow or by Andrew
Published on 2010-03-24T10:03:38Z Indexed on 2010/03/24 10:13 UTC
Read the original article Hit count: 490

Filed under:
|
|

I tryed to create a socket in php and reuse it from other process. I know this can be done with a daemon script but I want to do this without.

I created a socket and binded it to a specific port.

$sock = socket_create (AF_INET, SOCK_STREAM, SOL_TCP);  
socket_set_option ($sock, SOL_SOCKET, SO_REUSEADDR, 1); 
socket_bind ($sock, 'xx.xx.xx.xx', 10000);
socket_connect ($sock, $host, $port);

And from another php file I did the same thing. But the packets that I send from the 2 file are not "validated" by host. I sniffed all ports and I see that it uses same local and destination port. I don't understand where is the problem.

Can you help me with this? It's ok in any other programming language, or any other solution for this.

Andrew

© Stack Overflow or respective owner

Related posts about socket

Related posts about reusable