Results 1 to 3 of 3
Thread: simultaneous sockets in php
-
10-05-2008, 11:05 AM #1WHT Addict
- Join Date
- Aug 2001
- Posts
- 123
simultaneous sockets in php
I need to open 100+ outbound socket connections in PHP. But while that is happening I obviously need to maintain and read data from the sockets that are open. I looked at process control and fork but i don't want to have 100 processes running independently of each other. Thoughts?
My current implementation opens a socket and then reads from and maintains the other sockets that are open. But even a low timeout value on fsockopen() could cause data to excessively pile up in the socket buffers and cause packets to be dropped.
-
10-05-2008, 01:43 PM #2Web Hosting Guru
- Join Date
- May 2008
- Location
- FL
- Posts
- 337
PHP doesn't support threading, so I don't think you will be able to do what you want there. You could possibly use a language that supports threading, or break it up into bits and do only a few connections per job.
-
10-05-2008, 11:19 PM #3Backup Guru
- Join Date
- Feb 2002
- Location
- New York, NY
- Posts
- 4,618
Sounds like a good candidate for socket_select(). Written properly, your loop can send and receive data only when the OS is ready for it.
Scott Burns, President
BQ Internet Corporation
Remote Rsync and FTP backup solutions
*** http://www.bqbackup.com/ ***