PHP Sockets Usage

There are times when some accounts are suspended because of Socket Abuse.

This article explains:

  1. What are sockets,
  2. How they affect your hosting account,
  3. What is allowed,
  4. How to avoid suspension because of socket abuse

Sockets:

PHP uses built-in functions to create a communication channel between your website script and an external server or a 3rd party service.

Main methods of PHP sockets:

sockopen() - Opens a simple socket connection (most common for basic use)
socket_create() and socket_connect() - Lower-level socket functions (more control)
stream_socket_client() - Modern approach for stream-based connections
cURL functions - Higher-level abstraction for HTTP/HTTPS connections

Effect on Your Hosting Account:

On Profreehost, use of PHP sockets is, although allowed, but is limited to prevent abuse.

Specific ports are allowed only that’s how MySQL, SMTP (PORT 24/587) and FTP (PORT 21) work on our free hosting service. You can also connect and send requests to external websites.

But unfortunately, more ports cannot be opened on request.

Sometimes you may use 3rd party scripts to upload on your hosting account and as such may not have full knowledge of how the script is working.

If poorly optimized, such scripts can cause over-usage of sockets or can spam sockets. In this case, your specific hosting account might be suspended.

How to Prevent Suspension:

Get knowledge of the script you are using either from it’s documentation. If script developer does not provide documentation, it’s usually more headache than relief. Try to stay away from such scripts.

Many accounts are banned because they try to setup a gaming server which is not supported on free hosting and eventually end-up in suspension.