Results 1 to 3 of 3
  1. #1

    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.

  2. #2
    Join Date
    May 2008
    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.

  3. #3
    Join Date
    Feb 2002
    New York, NY
    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
    *** ***

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts