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

  • SEARCH
  • Home
  • 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 8111815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:15:26+00:00 2026-06-06T02:15:26+00:00

On an apache server using the worker MPM, is it somehow possible to open

  • 0

On an apache server using the worker MPM, is it somehow possible to open up multiple persistent sockets to the same TCP address?

When I do the following:

$SocketA = pfsockopen('tcp://domain.com', 80);
$SocketB = pfsockopen('tcp://domain.com', 80);

I get two independent socket resources, yet with the same underlying connection (I can tell because if I write to $SocketA I can read the remote response from $SocketB and vice versa). I would like to have two separate persistent connections.

Is this possible to do?

  • 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-06-06T02:15:27+00:00Added an answer on June 6, 2026 at 2:15 am

    It would be possible but you would need to use a different hostname/ip address for the second persistent connection.

    Reason being, if the host you are connecting to is exactly the same (host and port), it will return the existing persistent connection if it exists, rather than creating a new one.

    PHP tracks persistent connections by internally creating a hash value based on the host and port (source):

    spprintf(&hashkey, 0, "pfsockopen__%s:%ld", host, port);
    

    Therefore if you use the same host and port for $socketB you are going to get back the existing connection from $socketA. PHP stores this hash value along with the connection, so the next time you call pfsockopen, it regenerates the hash and then looks it up, if it finds it, the old connection is returned.

    On socket B, you could try connecting directly to the IP address, or alias some other hostname to the first one so you ultimately get 2 connections to the same location, but you trick PHP into creating 2 connections. These are both workarounds though and are not exactly portable.

    For the most part the answer is yes and no, you can’t use the same host and port to get 2 connections, but you could work around it using a trick which may be confusing or cause unforseen problems.

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

Sidebar

Related Questions

I am installing a server for PHP using FCGI and apache with worker MPM
I am trying to configure an apache server using mod_wsgi for dynamic mass hosting.
I am trying to connect to a secure server using Apache Commons HttpClient 3.1
My group is trying to build a server using Apache Thrift but we are
I wanted to deploy my app into my local server using apache and passenger.
I am using Server version: Apache/1.3.34 (Debian) mod_perl - 1.29 By refering to STDIN,
in windows (using apache as server), my file path directory will be C:\xampp\htdocs\mysvn\PhpDocumentor\phpdoc.php. But
I'm using Weblogic application server and Apache web server in my J2EE environment and
I am using Apache as a web server to rewrite urls. The pattern is
I'm using Apache's commons-net-2.2.jar to download a batch of files from a FTP server,

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.