From: daniele-dll at yahoo dot it Operating system: Windows\Linux PHP version: 5.0.0RC1 PHP Bug Type: Sockets related Bug description: Problems with connection of a non blocking socket
Description: ------------ Hi to all i'm tring to write a little application with PHP using Socket, the external module, not fsockopen function or similar. I've noticed that, with this, and previous version of php, that after i create a socket and set it as non blocking socket, when i try to connect using socket_get_option($SOCKET, SOL_SOCKET, SO_ERROR) i recive EVER 0 Instead i should recive 115 If socket_get_option, with these params, return 0, it mean that connection is done and i can send datas, but if i send datas i get a warning that say that socket is in a connection state so i can't send datas. There is some parts of code: $this->socket[$sock_id]['resource'] = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if (!is_resource($this->socket[$sock_id]['resource'])) die("Unable to create socket! " . socket_strerror(socket_last_error()) . "\r\n"); if (!socket_set_option($this->socket[$sock_id]['resource'], SOL_SOCKET, SO_REUSEADDR, 1)) { die("Unable to set to as REUSABLE socket! " . socket_strerror(socket_last_error($this->socket[$sock_id]['resource'])) . "\r\n"); after i set socket as reusable (but php gimme me the same problem without this line too) and, after, if i need, i bind socket to a specific IP and PORT after there is this code: @socket_connect($this->socket[$sock_id]['resource'], $this->socket[$sock_id]['remote_host'], $this->socket[$sock_id]['remote_port']); while (($ris = @socket_get_option($this->socket[$sock_id]['resource'], SOL_SOCKET, SO_ERROR)) == 115) { echo "--> " . $ris . "\r\n"; } echo "\r\n--> " . $ris . "\r\n"; If you run this code it will exit immedatly printing: --> 0 Infact, after, if you try to write to socket, you will get a warning I haven't modified php.ini, and i've tried to run this code, using only socket extension, on windows and on linux I use apache 1.3.29 on windows and on linux bye -- Edit bug report at http://bugs.php.net/?id=28136&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=28136&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=28136&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=28136&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=28136&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=28136&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=28136&r=needscript Try newer version: http://bugs.php.net/fix.php?id=28136&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=28136&r=support Expected behavior: http://bugs.php.net/fix.php?id=28136&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=28136&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=28136&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=28136&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28136&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=28136&r=dst IIS Stability: http://bugs.php.net/fix.php?id=28136&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=28136&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=28136&r=float