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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:15:29+00:00 2026-06-09T13:15:29+00:00

I have a small application I created to analyze the network connection. It runs

  • 0

I have a small application I created to analyze the network connection. It runs from a browser and connects to a local PHP/Apache server. It then asks PHP to send a ping packet through a raw socket. THe problem is that if the host I am trying to ping isn’t alive or won’t answer to pings, we never get an answer from the server.

I beleave the socket request lives until apache is restarted. I have been getting mixed results from my application lately and I am blaming apache using too many sockets. Currently I have set the AJAX call’s timeout and I was happy with it. But I really need to make PHP do the timeouting so that I won’t have 500,000 sockets open to an unreachable host.

Some sample code:

$sockconn = @socket_connect($socket, $target, null);
if(!$sockconn)
{
    $raw['error'] = socket_strerror(socket_last_error());
    $raw['status'] = false;
    return $raw;
}

This is the function that won’t timeout. I need to get it to timeout. Also PHP script execution time DOES NOT affect sockets.

I am clueless.

  • 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-09T13:15:30+00:00Added an answer on June 9, 2026 at 1:15 pm

    You can set timeouts for reading and sending using the following options:

    socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 1, 'usec' => 0));
    socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, array('sec' => 1, 'usec' => 0));
    

    Alternatively, you can use non-blocking sockets and periodically poll the socket to see if the remote host responded.

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

Sidebar

Related Questions

I am using asp.net .. i have created one small application.. I have Configure
I have created a small chatting application in C#, and started as a Console
I have developed a small application. I created a login panel for it. I
I have created a use case of a small application and now I have
I have created a small application, trying to understand the functionality of the LoaderManager
I have created an small application, in which I'm using Fluent Nhibernate. Application run
To describe my problem i have created a small application. At first the Usercontrol:
I have a small application which I created using jeweler. The jeweler generates a
I have created small test web application which makes use of LINQ to SQL.
I was tasked with creating a small application for college, and have created a

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.