Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6790103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:41:07+00:00 2026-05-26T17:41:07+00:00

From PHP.net: http://www.php.net/manual/en/function.pfsockopen.php I understand the gist of what this function accomplishes, but I’m

  • 0

From PHP.net:

http://www.php.net/manual/en/function.pfsockopen.php

I understand the gist of what this function accomplishes, but I’m still unclear as to whether this will accomplish what I’d like it to. Here is my scenario:

I have a large PHP application that is used by many users simultaneously. Within the application, I’m opening a TCP socket to a remote server for logging messages, etc… It was my hope that I might be able to leverage pfsockopen in order that many fewer connections would need to be opened. For example, user1 signs in – socket opens. User2 signs in, no socket is opened because he can “piggyback” on the socket opened by user1.

Is this possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T17:41:08+00:00Added an answer on May 26, 2026 at 5:41 pm

    pfsockopen will indeed keep the socket open when the script ends, allowing it to be re-used from a request to another, effectively opening less connections like you would expect. However, this is not compatible with all SAPIs.

    The persistence occurs on a per-process basis. As such, pfsockopen ran in a CLI SAPI will close and re-open a socket at every execution, because the CLI script is executed in a single process that starts, open a socket and ends (closing the socket along with the process).

    In CGI mode with one process per script, this is also true.

    With the Apache SAPI, it depends what type of multi-processing module (MPM) is in use. mpm-prefork spawns a new process at every request, so it most likely doesn’t support it. mpm-worker however, spawns threads, so it will probably work there. mpm-winnt is a Windows variant of a multi-threaded MPM, so it should work too.

    The worst that can happen is that the call will be executed as a normal fsockopen call.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following example is taken from: http://php.net/manual/en/function.curl-multi-close.php#example-3540 This example will create two cURL handles,
How do I return the comment property from exif_read_data link: http://www.php.net/manual/en/function.exif-read-data.php
According to: http://www.php.net/manual/en/function.filectime.php In most Unix filesystems, a file is considered changed when its
The PHP page of Soap Server (I've seen it): http://www.php.net/manual/en/soapserver.soapserver.php But I'm missing an
This is my code: function get_remote_file_to_cache(){ $sites_array = array(http://www.php.net, http://www.engadget.com, http://www.google.se, http://arstechnica.com, http://wired.com); $the_site=
from http://www.php.net/manual/en/class.pdo.php ###### config.ini ###### db_driver=mysql db_user=root db_password=924892xp [dsn] host=localhost port=3306 dbname=localhost [db_options] PDO::MYSQL_ATTR_INIT_COMMAND=set
from http://www.php.net/manual/en/class.pdo.php ###### config.ini ###### db_driver=mysql db_user=root db_password=924892xp [dsn] host=localhost port=3306 dbname=localhost [db_options] PDO::MYSQL_ATTR_INIT_COMMAND=set
Except https://www.php.net/manual/en/book.ktaglib.php and http://getid3.sourceforge.net/ does anyone know of any other way to work from
This example is from php.net: <?php function Test() { static $a = 0; echo
Tried examples from 'php.net' but don't understand what's the problem. Any suggestions? <?php $_SESSION['test']

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.