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 4587772
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:49:40+00:00 2026-05-21T21:49:40+00:00

To have cURL support, then php must be compiled –with-curl option. To have sockets

  • 0

To have cURL support, then php must be compiled –with-curl option.
To have sockets support, then php must be compiled with –enable-sockets option.
To have stream wrappers support for http, ftp … in functions like fopen, file_get_contents … then allow_url_fopen must be set to On in php.ini.

While most shared webhosting servers have all (or almost all) previous features enabled, some of them
may not have support for those features, because their optional status.

On the other hand streams are part of php core.
If somebody wants to make a verry portable(i think) php http client for example, not based on cURL,
socket, or wrappers(http) support, then, that can be done with:

$fp = stream_socket_client("tcp://example.com:80", $errno, $errstr);
fwrite($fp, "GET / HTTP/1.0\r\nHost: example.com\r\nAccept: */*\r\n\r\n");

using not a http stream wrapper but a stream transport wrapper(tcp) which is different.

I saw on my localhost that even when php.ini directive allow_url_fopen is set to Off,
I can make remote connection via stream_socket_client() using tcp transport.

My questions are:
1. Is there a way to block availability of core streams, except the possibility to disable functions like stream_socket_client or fsockopen in php.ini by hardcoding them like:

disable_functions = exec,passthru,shell_exec,stream_socket_client,fsockopen ...

???
2. Is the use of $fp = stream_socket_client('tcp://...',[...]); the most portable solution
for making remote connections, that can be turned later in http/ftp… requests by connecting first to the right port(e.g 80) and using fwrite($fp, 'GET /...'); to send low level http/ftp queries
to the remote server?

  • 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-21T21:49:41+00:00Added an answer on May 21, 2026 at 9:49 pm

    Hosting companies who wants to disable remote connections have probably already blocked all outgoing connections in the firewall, so even if they do (mistakenly, we can suppose) allow stream_socket_client, the connection itself may be blocked on the transport layer.

    If they don’t block it in their firewall, you still have two problems to overcome:

    • They probably will block stream_socket_client as soon as they find out about it
    • If they don’t know how (or care) to set up firewall rules for their connection policies, chances are they don’t know a lot about hosting security at all

    You should really avoid hosting companies which doesn’t allow the features you need. The hosting market is big with a lot of options so try to find one who fits your needs. Most hosters already allow outgoing connections and doesn’t block sockets and URL streams. cURL is built-in on almost all PHP builds (and almost all hosts as well).

    To answer your questions:

    1. Yes, they may block outgoing connections in the firewall. Even those hosts who allow url_fopen, cURL and so on routinely block traffic on most other ports than HTTP to make it hard for spammers, crackers and other blackhats.

    2. In the server context, maybe. It’s not so flexible with regards to things like cookies, redirects and so on. You still have to implement the HTTP protocol yourself, which may be easy for some solutions (if your for example just need a regular GET without cookies and such), but may be a hassle if you want support for cookie handling, redirections, error handling, HTTPS, file uploads and so on.

    Even if it may be a portable solution, I think you should focus on other things than writing a HTTP library. It’s not hard to find a host with cURL support or similar.

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

Sidebar

Related Questions

I have followed all the instructions here: http://www.tonyspencer.com/2003/10/22/curl-with-php-and-apache-on-windows/ to install & config apache get
I have noticed that cURL in PHP returns different data when told to output
I am using an encoded PHP script, which requires SSL support for CURL. I
I have been provided with the php info: http://elfs.se/phpinfo.php Theese are the instances that
I am scraping a list of RSS feeds by using cURL, and then I
I have a PHP app that I would like to test against various PHP
FirstData has horrendous customer support, but I have to integrate with their Global Gateway
does PHP support something like ampersand in bash (forking)? Let's say I wanted to
I have a command line php app that I need to distribute to a
Are there alternatives to PHP that perform faster and have somewhat the same feature

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.