Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.2.2

Bug #3372 net_socket needs to support stream transport specification to work w/ php 5
Submitted: 2005-02-03 16:52 UTC
From: liamr at umich dot edu Assigned: chagenbu
Status: Closed Package: Net_Socket
PHP Version: 5.0.3 OS: linux 2.4.28
Roadmaps: (Not assigned)    
Subscription  


 [2005-02-03 16:52 UTC] liamr at umich dot edu
Description: ------------ fsockopen in php5 seems to be pickier about requiring the stream transport specification ( 'tcp://', 'unix://', etc ) when opening sockets. PHP 4 would allow you to do... $fp = fsockopen( '/tmp/example.sock, 0, $errno, $errstr, 30 ); PHP 5 requires $fp = fsockopen( 'unix:///tmp/example.sock, 0, $errno, $errstr, 30 ); As Net_Socket::connect uses fsockopen and pfsockopen, it should be able to handle the transport specification, and currently doesn't. Reproduce code: --------------- $socket = &new Net_Socket(); $socket->connect( 'unix:///tmp/example.sock', 0, true, 30); Expected result: ---------------- A unix socket should get opened Actual result: -------------- If your /etc/resolv.conf contains.. search example.com Net_Socket tries to open a tcp socket to a host named unix:///tmp/example.sock.example.com 6294 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 4 6294 connect(4, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("www.xxx.yyy.zzz")}, 28) = 0 6294 send(4, "\254\320\1\0\0\1\0\0\0\0\0\0\21unix:///tmp/example.sock\5example\3com\0\0\ 1\0\1", 45, 0) = 45 6294 gettimeofday({1107447499, 264462}, NULL) = 0 6294 poll([{fd=4, events=POLLIN, revents=POLLIN}], 1, 5000) = 1 6294 ioctl(4, FIONREAD, [100]) = 0 6294 recvfrom(4, "\254\320\205\203\0\1\0\0\0\1\0\0\21unix:///tmp/example.sock\5example\3 com\0\0\1\0\1\300\36\0\6\0\1\0\0p\200\0+\3dns\3itd\300\36\nhostmaster\300\36\v\3 63k\20\0\0p\200\0\0008@\0$\352\0\0\0p\200", 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("www.xxx.yyy.zzz")}, [16]) = 100 6294 close(4) = 0

Comments

 [2005-02-03 17:20 UTC] liamr at umich dot edu
This patch seems to work... diff -U 2 /tmp/Socket.php Socket.php --- /tmp/Socket.php 2005-02-03 12:08:34.000000000 -0500 +++ Socket.php 2005-02-03 12:10:12.000000000 -0500 @@ -102,5 +102,5 @@ if (!$addr) { return $this->raiseError('$addr cannot be empty'); - } elseif (strspn($addr, '.0123456789') == strlen($addr) || substr($addr, 0, 1) == '/') { + } elseif (strspn($addr, '.0123456789') == strlen($addr) || substr($addr, 0, 1) == '/' || strstr($addr, '://')) { $this->addr = $addr; } else {
 [2005-02-03 20:40 UTC] chagenbu
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better.