php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38568 Problem when opening a socket with fsockopen() (HP-UX only)
Submitted: 2006-08-23 15:04 UTC Modified: 2007-01-18 01:00 UTC
Votes:5
Avg. Score:3.8 ± 1.6
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:3 (100.0%)
From: pierre-marie dot mouliere at arc-intl dot com Assigned:
Status: No Feedback Package: Sockets related
PHP Version: 5.1.5 OS: HP-UX B.11.23 (Itanium IA64)
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-08-23 15:04 UTC] pierre-marie dot mouliere at arc-intl dot com
Description:
------------
Symptom : 
When opening a socket with fsockopen() the following error occurs : fsockopen(): unable to connect to x.x.x.net:80 (Operation now in progress) in testsocket.php

We locate the problem in the source code     
Problem is in network.c, in 'main' directory, near line 328

Function getsockopt() returns code EINPROGRESS in 'error' field. So function exits with ret = -1 (third line from end  here), although EINPROGRESS is not really an error.
We have implemented the following workaround (3 lines) between /* Start changes */ and /* End changes */ and it's fixed




Reproduce code:
---------------
----------------------------------------------------------
ok:
   if (!asynchronous) {
      /* back to blocking mode */
      RESTORE_SOCKET_BLOCKING_MODE(sockfd, orig_flags);
   }
/* Start changes */
   if (error == EINPROGRESS) {
       error = 0;
   }
/* End changes */
   if (error_code) {
      *error_code = error;
   }
   if (error && error_string) {
     *error_string = php_socket_strerror(error, NULL, 0);
     ret = -1;
   }
   return ret;
----------------------------------------------------------

            



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-23 15:50 UTC] tony2001@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.



 [2006-08-23 16:21 UTC] pierre-marie dot mouliere at arc-intl dot com
Hello, 
It's difficult to give more information. 
The php source code to test is 
<?php
  $sk = fsockopen("dev2.emea.dmai.net",80);
  echo "socket = " . $sk;
?>
May be the problem in only on HPUX. We found a solution to fixed it. It's running and for us it's OK now. But we prefer to include our sources change of network.c in the global release. If not, we need to change source code at each releases. 
Best regards
Pierre Marie MOULIERE
 [2006-08-23 16:38 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2006-08-24 05:54 UTC] pierre-marie dot mouliere at arc-intl dot com
Hello Tony,
We try to use the new package. The result is exactly the same. the network.c files doesn't change except a static const declare. So, I'm not surprised that we have the same result. 
We use also PHP for windows and on HPUX 32 Bits and we have no problem. The problem in only on new 64 Bits HPUX.
Best regards
Pierre Marie
 [2006-08-24 08:03 UTC] tony2001@php.net
>We use also PHP for windows and on HPUX 32 Bits and we
>have no problem. The problem in only on new 64 Bits HPUX.

I guess the problem is not _on_ 64bit HPUX, but _in_ 64bit HPUX. Did you try to look into their docs/bugs/contact support etc? 
I've serious doubts we're going to commit patches changing behaviour on all systems because of a broken 64bit HPUX.
 [2006-08-24 10:10 UTC] pierre-marie dot mouliere at arc-intl dot com
You are right,
But I think that this update will be ok for all others systems because the error EINPROGRESS is not a real error after the getsockopt() function (no block mode)
It's seen that the open socket is still in progress when the getsockopt() function is call.
We look for HP support and we found no patches and no information about this 
the getsockopt() return code is OK  
To detect it we use TUSC Tools 
-------
socket(AF_INET, SOCK_STREAM, 0) .......................... = 3
fcntl(3, F_GETFL, 0) ..................................... = 2
fcntl(3, F_SETFL, 65538) ................................. = 0
connect(3, 0x60000000002ead58, 16) ....................... ERR#245 EINPROGRESS
poll(0x9fffffffffffce38, 1, 60000) ....................... = 1
getsockopt(3, SOL_SOCKET, SO_ERROR, 0x9fffffffffffce30, 0x9fffffffffffce40) = 0
fcntl(3, F_SETFL, 2) ..................................... = 0
open("/usr/lib/nls/msg/C/strerror.cat", O_RDONLY|0x800, 0113572) = 4
-------
 [2006-12-14 10:06 UTC] nlopess at _php dot net
http://lxr.php.net/source/php-src/main/network.c#277 seems to already account for EINPROGRESS, and it polls the connection when in blocking mode.
 [2007-01-10 21:51 UTC] iliaa@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2007-01-18 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Jan 27 21:03:35 2022 UTC