Click to See Complete Forum and Search --> : PHP sockets theoretic question


tamirvs
September 6th, 2010, 09:29 AM
Hey,
I have PHP file which listens to connections using sockets.
the clients are C++ applications which open the PHP file (to make it listen) and then connect.
my question is, what if 2 different applications open the PHP file? will it open 2 different PHP servers? or will it "re-open" the same server each time?
it's kinda messy question but i hope you understood.. :)
Thakns!

PeejAvery
September 6th, 2010, 06:02 PM
Sockets can only connect to one port per instance. Duplicating a socket with an open port will be blocked due to port being in use.

tamirvs
September 7th, 2010, 09:40 AM
Hmm yea, you right, didn't think about it. Thanks! :)

cverhoeven
September 20th, 2010, 10:04 AM
It may be possible to connect to the php script and negociate a port for further communication. For example, client connects on port 80, php file answers "7038" and with proper webserver config it may be possible to have the client connect back to this port, and continue communication here.