#34851 [Asn->Csd]: SO_RECVTIMEO and SO_SNDTIMEO socket options expect integer parameter on windows

From: Date: Thu, 03 Nov 2005 15:02:32 +0000
Subject: #34851 [Asn->Csd]: SO_RECVTIMEO and SO_SNDTIMEO socket options expect integer parameter on windows
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-87479@lists.php.net to get a copy of this message
 ID:               34851
 Updated by:       mike@php.net
-Summary:          SO_RECVTIMEO sec stands for usec!!!! and usec has no
                   effect!
 Reported By:      khayll at motoros dot hu
-Status:           Assigned
+Status:           Closed
 Bug Type:         Sockets related
-Operating System: win 2k3 server
+Operating System: win32 only
-PHP Version:      4.4.0
+PHP Version:      *
 Assigned To:      mike
 New Comment:

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------

[2005-10-25 20:09:59] mike@php.net

Target for 4.4.2

------------------------------------------------------------------------

[2005-10-14 15:24:32] mike@php.net

Ok, ok, my last comment :)

The real problem seems to be that windows expects a DWORD and not a
timeval as parameter.


------------------------------------------------------------------------

[2005-10-14 15:08:03] mike@php.net

But I cannot reproduce either, here's what I receive (base64),
without warnings (on Win2k):

PHP-4.3.8: "UukAAAAXAQMUcmV2LjIuMiAgIAAAAgFQMUVSSyA="
PHP-5-CVS: "/AoAAAAXAQMUcmV2LjIuMiAgIAAAAgFQMUVSSyA="


------------------------------------------------------------------------

[2005-10-14 14:36:03] mike@php.net

Winsock implementation does not support all BSD options for setsockopt,
SO_RCVTIMEO is within these.




------------------------------------------------------------------------

[2005-10-13 18:18:23] khayll at motoros dot hu

Please read carefully what I wrote...

If I use 0 sec and 500 usec, the script HANGS when there's no response
(which means usec has NO EFFECT)! (Sorry I cannot reproduce remote
machine not sending a response, but accepting connections) and with a
setting of 1 sec 0 usec which is pretty much for a response I get a
timeout error.

here execute this script and it will show you the script execution time
is less than 1 sec at all giving a timeout:

<?php

	echo microtime()."<br>\n";

	$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
	socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array("sec"=>1,
"usec"=>0));
	socket_connect($socket, "81.182.13.109", "502");

	$pdu = "";
	$pdu .= chr(0x03).chr(floor(16000 / 256)).chr(16000 %
256).chr(floor(10 / 256)).chr(10 % 256);

	$rand = mt_rand(1,65535); //generate random adu id
	$adu = "";
	$adu .= chr(floor($rand / 256)).chr($rand %
256).chr(0).chr(0).chr(floor(6 / 256)).chr(6 % 256).chr(1);
	
	$data = $adu.$pdu;

	socket_write($socket, $data, strlen($data));

	$result = socket_read($socket, 512, PHP_BINARY_READ);

	if($result===false)	echo
socket_strerror(socket_last_error())."<br>\n";

	socket_shutdown($socket, 2);
	socket_close($socket);

	echo microtime()."<br>\n";

?>

result:

0.32968200 1129220264

Warning: socket_read() unable to read from socket [0]: A connection
attempt failed because the connected party did not properly respond
after a period of time, or established connection failed because
connected host has failed to respond. in
c:\data\web\rtu\rtu_web\phpbug.php on line 20
A connection attempt failed because the connected party did not
properly respond after a period of time, or established connection
failed because connected host has failed to respond. 
0.89507800 1129220264

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/34851

-- 
Edit this bug report at http://bugs.php.net/?id=34851&edit=1


Thread (14 messages)

« previous php.bugs (#87479) next »