[PHP] Is the php sockets extension experimental?
Hello, in the packet description of the php5-sockets in the SuSE Linux Enterprise Server 11 (SLES11) is the package php5-sockets in the additional SDK available, but marked as experimental (see below). Is this the true, where can I find this Information, or is this only a historical relic? Are there differences in this extension between PHP 5.2.x, 5.3.x and 5.4? Can I rely on this the extension for a productive environment? Thanks in advance, Meike == ~ # zypper info php5-sockets Refreshing service 'SMT-http_delds01_entiretec_com'. Loading repository data... Reading installed packages... Information for package php5-sockets: Repository: SLES11SP2-SDK Name: php5-sockets Version: 5.2.14-0.7.24.1 Arch: x86_64 Vendor: SUSE LINUX Products GmbH, Nuernberg, Germany Support Level: unknown Installed: No Status: not installed Installed Size: 45.0 KiB Summary: PHP5 Extension Module Description: A low-level interface to the socket communication functionsbased on the popular BSD sockets, providing the possibilityto act as a socket server as well as a client.This extension is experimental! == -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is the php sockets extension experimental?
On Wed, Mar 28, 2012 at 09:39, Meike Stone meike.st...@googlemail.com wrote: Hello, in the packet description of the php5-sockets in the SuSE Linux Enterprise Server 11 (SLES11) is the package php5-sockets in the additional SDK available, but marked as experimental (see below). Is this the true, where can I find this Information, or is this only a historical relic? Are there differences in this extension between PHP 5.2.x, 5.3.x and 5.4? Can I rely on this the extension for a productive environment? Everything you need to know is here: http://php.net/sockets Description: A low-level interface to the socket communication functionsbased on the popular BSD sockets, providing the possibilityto act as a socket server as well as a client.This extension is experimental! Sounds like the package maintainer is a minimum of six years behind the times, or they've done some forking to it. We don't support any third-party packages, so that would be something you'd need to discuss with them, but - in all likelihood - someone just hasn't removed the experimental tag yet. -- /Daniel P. Brown Network Infrastructure Manager http://www.php.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is the php sockets extension experimental?
Hello, Sounds like the package maintainer is a minimum of six years behind the times, or they've done some forking to it. We don't support any third-party packages, so that would be something you'd need to discuss with them, but - in all likelihood - someone just hasn't removed the experimental tag yet. Thanks for the fast answer. That's, what I suspected. Kindly regards Meike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP sockets enabled but socket_create() gives an error call to undefined function
We added the extension=sockets.so to php.ini but it didn't work. However, the problem was there was no sockets.so extension anywhere to be found. i searched if I could install or add sockets.so extension. Couldn't find anything. Still looking for it. Thank you for all the help. -Suyash On Tue, Nov 2, 2010 at 5:30 PM, Nicholas Kell n...@monkeyknight.com wrote: On Nov 2, 2010, at 3:23 PM, Suyash R wrote: No, our dept.'s admin wants to know where is sockets.so file on disk and why should we try this when the phpinfo() displays sockets being enabled? Can help me find sockets.so file I don't know where it is It's a shared object right are they stored on disk as individual files or all together compiled into a binary Thank you Suyash Ramineni On Tue, Nov 2, 2010 at 3:55 PM, Nicholas Kell n...@monkeyknight.com wrote: On Nov 2, 2010, at 2:50 PM, Suyash R wrote: My admin disagrees and I have questions too. The phpinfo() fuction displays that sockets have been enabled. If extension=sockets.so is an alternate way to enable sockets, then why should this be done twice? Suyash Ramineni On Mon, Nov 1, 2010 at 2:35 PM, Nicholas Kell n...@monkeyknight.com wrote: On Nov 1, 2010, at 1:12 PM, Suyash R wrote: No, sockets.so in not included in any of the machines php.ini file. However, I found that Linux machine's php.ini doesn't include sockets.so and sockets work fine on it but don't work on the Solaris machine. Is it required to be included only in Solaris? On Mon, Nov 1, 2010 at 1:41 PM, Nicholas Kell n...@monkeyknight.com wrote: On Nov 1, 2010, at 12:08 PM, crrr errr wrote: Yes, the http ( Apache user) has rl ( read permission) on the php file with sockets code in it. I think write access is unnecessary for Apache user. On Mon, Nov 1, 2010 at 12:50 PM, Nicholas Kell n...@monkeyknight.com wrote: On Nov 1, 2010, at 11:44 AM, crrr errr wrote: Yes, the phpinfo() shows that sockets are enabled in both machines. On Mon, Nov 1, 2010 at 12:43 PM, Bastien Koert phps...@gmail.com wrote: On Mon, Nov 1, 2010 at 12:40 PM, crrr errr r.suy...@gmail.com wrote: Hello, I was trying to create a socket connection from a Solaris machine to a Red Hat machine to get the PATH in Red Hat machine remotely on Solaris machine and display it to the user. We have a PHP 5.1.6 installation on a Linux server (Apache) and PHP 5.2.6. on a Unix(Solaris) server(Apache) . The PHP version on Solaris is compiled with --enable sockets and phpinfo() displays that the sockets are enabled. In spite of this we get the following error when using this piece of code from the Solaris machine. The error: PHP Fatal error: Call to undefined function socket_create() in /XXX/ 5server.php http://cad.njit.edu/u/d/x/dx8/public_html/clunk/swsearch5server.php on line 21 The code; ?php set_time_limit(0); //ip of the server $addr = 'xxx.xxx.xxx.xxx'; //port of the server $port = 2xxx; //create a socket $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); /* This is line no 21 in the code. i have ommitted a few header comments */ //bind this socket with the above ip and port $ret = socket_bind($sock, $addr, $port); do { $ret = socket_listen($sock, 10); $msgSock = socket_accept($sock); $buf = socket_read($msgSock, 1024); Please let me know if you need any further details I might have missed. Thank you. Suyash Ramineni check phpinfo() to see if the sockets have been activated in the ini file. -- Bastien Cat, the other other white meat I think that I messed up sending my last email, I apologize. Is the user that Apache is running under configured for the proper read write access to the socket file? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Oops, included in php.ini, not the Apache config. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Since you complied with --enable-sockets, you shouldn't even need sockets.so to be dynamically loaded. But at this point, it is something that I would try anyway. Add: extension=sockets.so in your php.ini file just to see if it brings the function to light. Your Linux installs I am sure were compiled with it in it. Especially if it is a dist package. The absence of the function is telling me that PHP is not compiled with --enable-sockets. If it was compiled in properly, you would be getting different errors. I am not saying that you didn't do it. Something may have happened in
Re: [PHP] PHP sockets enabled but socket_create() gives an error call to undefined function
On Tue, Nov 2, 2010 at 5:49 PM, Nathan Nobbe quickshif...@gmail.com wrote: On Tue, Nov 2, 2010 at 2:33 PM, Suyash R r.suy...@gmail.com wrote: No, we didn't try it our dept.'s admin wants to know where is sockets.so file on disk lol, tell your dept.'s 'admin' to run locate sockets.so yeah he couldn't find it either. He mentioned it's not in the php extensions so I am looking for way to install it or add it. and why should we try this when the phpinfo() displays sockets being enabled? probly there is no need to, however you should understand the difference between adding support for and enabling an extension. compiling w/ --enable only makes the extension available. the extension is not enabled unless you do what Nick has been saying. (there are other options as well actually). there may be other files aside from php.ini where this setting is made, depending on how the OS vendors package up the code. for example using mac ports, i just installed sockets and now have a shiny new sockets.ini file. anyway if phpinfo() shows that sockets are enabled you probly don't have to worry about that, because it wouldn't be showing up otherwise (essentially). i'm wondering if you're trying to call socket_create() from the same place you're running phpinfo(). are you sure the socket_create() code isn't running from the cli perhaps? yes to see the errors we ran it at cli. The browser page with sockets code is just blank. if so, a quick test to see if sockets are enabled on the cli is php -i | grep 'Sockets Support' Yeah, this gives no results. Hence, I think sockets are not enabled yet as sockets.so is missing. if nothing comes back sockets aren't enabled for the cli. if that's the case then you will have to head into the appropriate ini file to enable the extension for the cli. or if that's too much for you admin you can always try dl('sockets.so'); at the top of your script. you can also try var_dump(extension_loaded('sockets')); When I add this line (dl('sockets.so');) to the top of my script I get the following error: PHP Warning: dl(): Unable to load dynamic library './sockets.so' - ld.so.1: php: fatal: ./sockets.so: open failed: No such file or directory in //r.php on line 2 PHP Fatal error: Call to undefined function socket_create() in /.r.php on line 24 When I add this line (var_dump(extension_loaded('sockets'));) to the top of my script: bool(false) PHP Fatal error: Call to undefined function socket_create() in /../r.php on line 24 to see if sockets are actually enabled where you're trying to invoke them from. -nathan Can I get any help on how to add or install sockets.so to the php extensions... -Suyash
Re: [PHP] PHP sockets enabled but socket_create() gives an error call to undefined function
On Thu, Nov 4, 2010 at 11:11 AM, Suyash R r.suy...@gmail.com wrote: On Tue, Nov 2, 2010 at 5:49 PM, Nathan Nobbe quickshif...@gmail.comwrote: On Tue, Nov 2, 2010 at 2:33 PM, Suyash R r.suy...@gmail.com wrote: No, we didn't try it our dept.'s admin wants to know where is sockets.so file on disk lol, tell your dept.'s 'admin' to run locate sockets.so yeah he couldn't find it either. He mentioned it's not in the php extensions so I am looking for way to install it or add it. you may need to update the locate database. this is typically done w/ the updatedb command. and why should we try this when the phpinfo() displays sockets being enabled? probly there is no need to, however you should understand the difference between adding support for and enabling an extension. compiling w/ --enable only makes the extension available. the extension is not enabled unless you do what Nick has been saying. (there are other options as well actually). there may be other files aside from php.ini where this setting is made, depending on how the OS vendors package up the code. for example using mac ports, i just installed sockets and now have a shiny new sockets.ini file. anyway if phpinfo() shows that sockets are enabled you probly don't have to worry about that, because it wouldn't be showing up otherwise (essentially). i'm wondering if you're trying to call socket_create() from the same place you're running phpinfo(). are you sure the socket_create() code isn't running from the cli perhaps? yes to see the errors we ran it at cli. The browser page with sockets code is just blank. right, well if your report from the other day is accurate then it sounds like you have sockets setup in the web environment and not the cli. if the browser page is blank it could be b/c your not outputting anything from your script to the browser. if so, a quick test to see if sockets are enabled on the cli is php -i | grep 'Sockets Support' Yeah, this gives no results. Hence, I think sockets are not enabled yet as sockets.so is missing. run updatedb first before running locate and see if it's there or not. im not sure how phpinfo() could possibly have reported sockets as being enabled if you were missing sockets.so. if nothing comes back sockets aren't enabled for the cli. if that's the case then you will have to head into the appropriate ini file to enable the extension for the cli. or if that's too much for you admin you can always try dl('sockets.so'); at the top of your script. you can also try var_dump(extension_loaded('sockets')); When I add this line (dl('sockets.so');) to the top of my script I get the following error: PHP Warning: dl(): Unable to load dynamic library './sockets.so' - ld.so.1: php: fatal: ./sockets.so: open failed: No such file or directory in //r.php on line 2 PHP Fatal error: Call to undefined function socket_create() in /.r.php on line 24 When I add this line (var_dump(extension_loaded('sockets'));) to the top of my script: bool(false) PHP Fatal error: Call to undefined function socket_create() in /../r.php on line 24 so it's def not enabled on the cli. to see if sockets are actually enabled where you're trying to invoke them from. -nathan Can I get any help on how to add or install sockets.so to the php extensions... im not much for red hat, do they even use yum on that system or is it still rpm? on a centos box we have a quick search turns up a sockets package, however if you built from source, i doubt that's how you want to install sockets support at this point. $ yum search php | grep -i socket php-pear-Net-Socket.noarch : Network Socket Interface also dude, it sounds like your admin is struggling... these questions are the sort an admin would be expected to answer pretty much anywhere ive ever worked. like, how do i install software on the os im responsible for .. OUCH! -nathan
Re: [PHP] PHP sockets enabled but socket_create() gives an error call to undefined function
On Thu, Nov 4, 2010 at 11:43 AM, Nathan Nobbe quickshif...@gmail.comwrote: $ yum search php | grep -i socket php-pear-Net-Socket.noarch : Network Socket Interface check that - thats def *not* the package you're looking for, it's a userspace oo wrapper. you'd be best asking how to install this software on some sort of red hat / php list really. like i said, i tend to stay away from red hat. the gentoo guys have #gentoo-php on irc so i would expect there to be similar channels for other distros. still though, update the locate database and see if you just need to enable sockets in a cli specific ini file. -nathan
Re: [PHP] PHP sockets enabled but socket_create() gives an error call to undefined function
On Thu, 2010-11-04 at 11:48 -0600, Nathan Nobbe wrote: On Thu, Nov 4, 2010 at 11:43 AM, Nathan Nobbe quickshif...@gmail.comwrote: $ yum search php | grep -i socket php-pear-Net-Socket.noarch : Network Socket Interface check that - thats def *not* the package you're looking for, it's a userspace oo wrapper. you'd be best asking how to install this software on some sort of red hat / php list really. like i said, i tend to stay away from red hat. the gentoo guys have #gentoo-php on irc so i would expect there to be similar channels for other distros. still though, update the locate database and see if you just need to enable sockets in a cli specific ini file. -nathan is there a PEAR module you can install that will do this? I know there are a lot of PEAR modules out there... just a thought... Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP sockets enabled but socket_create() gives an error call to undefined function
Hello, I was trying to create a socket connection from a Solaris machine to a Red Hat machine to get the PATH in Red Hat machine remotely on Solaris machine and display it to the user. We have a PHP 5.1.6 installation on a Linux server (Apache) and PHP 5.2.6. on a Unix(Solaris) server(Apache) . The PHP version on Solaris is compiled with --enable sockets and phpinfo() displays that the sockets are enabled. In spite of this we get the following error when using this piece of code from the Solaris machine. The error: PHP Fatal error: Call to undefined function socket_create() in /XXX/ 5server.phphttp://cad.njit.edu/u/d/x/dx8/public_html/clunk/swsearch5server.php on line 21 The code; ?php set_time_limit(0); //ip of the server $addr = 'xxx.xxx.xxx.xxx'; //port of the server $port = 2xxx; //create a socket $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); /* This is line no 21 in the code. i have ommitted a few header comments */ //bind this socket with the above ip and port $ret = socket_bind($sock, $addr, $port); do { $ret = socket_listen($sock, 10); $msgSock = socket_accept($sock); $buf = socket_read($msgSock, 1024); Please let me know if you need any further details I might have missed. Thank you. Suyash Ramineni
Re: [PHP] PHP sockets enabled but socket_create() gives an error call to undefined function
On Mon, Nov 1, 2010 at 12:40 PM, crrr errr r.suy...@gmail.com wrote: Hello, I was trying to create a socket connection from a Solaris machine to a Red Hat machine to get the PATH in Red Hat machine remotely on Solaris machine and display it to the user. We have a PHP 5.1.6 installation on a Linux server (Apache) and PHP 5.2.6. on a Unix(Solaris) server(Apache) . The PHP version on Solaris is compiled with --enable sockets and phpinfo() displays that the sockets are enabled. In spite of this we get the following error when using this piece of code from the Solaris machine. The error: PHP Fatal error: Call to undefined function socket_create() in /XXX/ 5server.phphttp://cad.njit.edu/u/d/x/dx8/public_html/clunk/swsearch5server.php on line 21 The code; ?php set_time_limit(0); //ip of the server $addr = 'xxx.xxx.xxx.xxx'; //port of the server $port = 2xxx; //create a socket $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); /* This is line no 21 in the code. i have ommitted a few header comments */ //bind this socket with the above ip and port $ret = socket_bind($sock, $addr, $port); do { $ret = socket_listen($sock, 10); $msgSock = socket_accept($sock); $buf = socket_read($msgSock, 1024); Please let me know if you need any further details I might have missed. Thank you. Suyash Ramineni check phpinfo() to see if the sockets have been activated in the ini file. -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP sockets enabled but socket_create() gives an error call to undefined function
Yes, the phpinfo() shows that sockets are enabled in both machines. On Mon, Nov 1, 2010 at 12:43 PM, Bastien Koert phps...@gmail.com wrote: On Mon, Nov 1, 2010 at 12:40 PM, crrr errr r.suy...@gmail.com wrote: Hello, I was trying to create a socket connection from a Solaris machine to a Red Hat machine to get the PATH in Red Hat machine remotely on Solaris machine and display it to the user. We have a PHP 5.1.6 installation on a Linux server (Apache) and PHP 5.2.6. on a Unix(Solaris) server(Apache) . The PHP version on Solaris is compiled with --enable sockets and phpinfo() displays that the sockets are enabled. In spite of this we get the following error when using this piece of code from the Solaris machine. The error: PHP Fatal error: Call to undefined function socket_create() in /XXX/ 5server.php http://cad.njit.edu/u/d/x/dx8/public_html/clunk/swsearch5server.php on line 21 The code; ?php set_time_limit(0); //ip of the server $addr = 'xxx.xxx.xxx.xxx'; //port of the server $port = 2xxx; //create a socket $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); /* This is line no 21 in the code. i have ommitted a few header comments */ //bind this socket with the above ip and port $ret = socket_bind($sock, $addr, $port); do { $ret = socket_listen($sock, 10); $msgSock = socket_accept($sock); $buf = socket_read($msgSock, 1024); Please let me know if you need any further details I might have missed. Thank you. Suyash Ramineni check phpinfo() to see if the sockets have been activated in the ini file. -- Bastien Cat, the other other white meat
Re: [PHP] PHP sockets enabled but socket_create() gives an error call to undefined function
On Nov 1, 2010, at 11:44 AM, crrr errr wrote: Yes, the phpinfo() shows that sockets are enabled in both machines. On Mon, Nov 1, 2010 at 12:43 PM, Bastien Koert phps...@gmail.com wrote: On Mon, Nov 1, 2010 at 12:40 PM, crrr errr r.suy...@gmail.com wrote: Hello, I was trying to create a socket connection from a Solaris machine to a Red Hat machine to get the PATH in Red Hat machine remotely on Solaris machine and display it to the user. We have a PHP 5.1.6 installation on a Linux server (Apache) and PHP 5.2.6. on a Unix(Solaris) server(Apache) . The PHP version on Solaris is compiled with --enable sockets and phpinfo() displays that the sockets are enabled. In spite of this we get the following error when using this piece of code from the Solaris machine. The error: PHP Fatal error: Call to undefined function socket_create() in /XXX/ 5server.php http://cad.njit.edu/u/d/x/dx8/public_html/clunk/swsearch5server.php on line 21 The code; ?php set_time_limit(0); //ip of the server $addr = 'xxx.xxx.xxx.xxx'; //port of the server $port = 2xxx; //create a socket $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); /* This is line no 21 in the code. i have ommitted a few header comments */ //bind this socket with the above ip and port $ret = socket_bind($sock, $addr, $port); do { $ret = socket_listen($sock, 10); $msgSock = socket_accept($sock); $buf = socket_read($msgSock, 1024); Please let me know if you need any further details I might have missed. Thank you. Suyash Ramineni check phpinfo() to see if the sockets have been activated in the ini file. -- Bastien Cat, the other other white meat I think that I messed up sending my last email, I apologize. Is the user that Apache is running under configured for the proper read write access to the socket file? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP sockets enabled but socket_create() gives an error call to undefined function
Yes, the http ( Apache user) has rl ( read permission) on the php file with sockets code in it. I think write access is unnecessary for Apache user. On Mon, Nov 1, 2010 at 12:50 PM, Nicholas Kell n...@monkeyknight.comwrote: On Nov 1, 2010, at 11:44 AM, crrr errr wrote: Yes, the phpinfo() shows that sockets are enabled in both machines. On Mon, Nov 1, 2010 at 12:43 PM, Bastien Koert phps...@gmail.com wrote: On Mon, Nov 1, 2010 at 12:40 PM, crrr errr r.suy...@gmail.com wrote: Hello, I was trying to create a socket connection from a Solaris machine to a Red Hat machine to get the PATH in Red Hat machine remotely on Solaris machine and display it to the user. We have a PHP 5.1.6 installation on a Linux server (Apache) and PHP 5.2.6. on a Unix(Solaris) server(Apache) . The PHP version on Solaris is compiled with --enable sockets and phpinfo() displays that the sockets are enabled. In spite of this we get the following error when using this piece of code from the Solaris machine. The error: PHP Fatal error: Call to undefined function socket_create() in /XXX/ 5server.php http://cad.njit.edu/u/d/x/dx8/public_html/clunk/swsearch5server.php on line 21 The code; ?php set_time_limit(0); //ip of the server $addr = 'xxx.xxx.xxx.xxx'; //port of the server $port = 2xxx; //create a socket $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); /* This is line no 21 in the code. i have ommitted a few header comments */ //bind this socket with the above ip and port $ret = socket_bind($sock, $addr, $port); do { $ret = socket_listen($sock, 10); $msgSock = socket_accept($sock); $buf = socket_read($msgSock, 1024); Please let me know if you need any further details I might have missed. Thank you. Suyash Ramineni check phpinfo() to see if the sockets have been activated in the ini file. -- Bastien Cat, the other other white meat I think that I messed up sending my last email, I apologize. Is the user that Apache is running under configured for the proper read write access to the socket file? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP sockets enabled but socket_create() gives an error call to undefined function
On Nov 1, 2010, at 12:08 PM, crrr errr wrote: Yes, the http ( Apache user) has rl ( read permission) on the php file with sockets code in it. I think write access is unnecessary for Apache user. On Mon, Nov 1, 2010 at 12:50 PM, Nicholas Kell n...@monkeyknight.com wrote: On Nov 1, 2010, at 11:44 AM, crrr errr wrote: Yes, the phpinfo() shows that sockets are enabled in both machines. On Mon, Nov 1, 2010 at 12:43 PM, Bastien Koert phps...@gmail.com wrote: On Mon, Nov 1, 2010 at 12:40 PM, crrr errr r.suy...@gmail.com wrote: Hello, I was trying to create a socket connection from a Solaris machine to a Red Hat machine to get the PATH in Red Hat machine remotely on Solaris machine and display it to the user. We have a PHP 5.1.6 installation on a Linux server (Apache) and PHP 5.2.6. on a Unix(Solaris) server(Apache) . The PHP version on Solaris is compiled with --enable sockets and phpinfo() displays that the sockets are enabled. In spite of this we get the following error when using this piece of code from the Solaris machine. The error: PHP Fatal error: Call to undefined function socket_create() in /XXX/ 5server.php http://cad.njit.edu/u/d/x/dx8/public_html/clunk/swsearch5server.php on line 21 The code; ?php set_time_limit(0); //ip of the server $addr = 'xxx.xxx.xxx.xxx'; //port of the server $port = 2xxx; //create a socket $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); /* This is line no 21 in the code. i have ommitted a few header comments */ //bind this socket with the above ip and port $ret = socket_bind($sock, $addr, $port); do { $ret = socket_listen($sock, 10); $msgSock = socket_accept($sock); $buf = socket_read($msgSock, 1024); Please let me know if you need any further details I might have missed. Thank you. Suyash Ramineni check phpinfo() to see if the sockets have been activated in the ini file. -- Bastien Cat, the other other white meat I think that I messed up sending my last email, I apologize. Is the user that Apache is running under configured for the proper read write access to the socket file? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Are you including sockets.so in Apache config?
Re: [PHP] PHP sockets enabled but socket_create() gives an error call to undefined function
On Nov 1, 2010, at 12:08 PM, crrr errr wrote: Yes, the http ( Apache user) has rl ( read permission) on the php file with sockets code in it. I think write access is unnecessary for Apache user. On Mon, Nov 1, 2010 at 12:50 PM, Nicholas Kell n...@monkeyknight.comwrote: On Nov 1, 2010, at 11:44 AM, crrr errr wrote: Yes, the phpinfo() shows that sockets are enabled in both machines. On Mon, Nov 1, 2010 at 12:43 PM, Bastien Koert phps...@gmail.com wrote: On Mon, Nov 1, 2010 at 12:40 PM, crrr errr r.suy...@gmail.com wrote: Hello, I was trying to create a socket connection from a Solaris machine to a Red Hat machine to get the PATH in Red Hat machine remotely on Solaris machine and display it to the user. We have a PHP 5.1.6 installation on a Linux server (Apache) and PHP 5.2.6. on a Unix(Solaris) server(Apache) . The PHP version on Solaris is compiled with --enable sockets and phpinfo() displays that the sockets are enabled. In spite of this we get the following error when using this piece of code from the Solaris machine. The error: PHP Fatal error: Call to undefined function socket_create() in /XXX/ 5server.php http://cad.njit.edu/u/d/x/dx8/public_html/clunk/swsearch5server.php on line 21 The code; ?php set_time_limit(0); //ip of the server $addr = 'xxx.xxx.xxx.xxx'; //port of the server $port = 2xxx; //create a socket $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); /* This is line no 21 in the code. i have ommitted a few header comments */ //bind this socket with the above ip and port $ret = socket_bind($sock, $addr, $port); do { $ret = socket_listen($sock, 10); $msgSock = socket_accept($sock); $buf = socket_read($msgSock, 1024); Please let me know if you need any further details I might have missed. Thank you. Suyash Ramineni check phpinfo() to see if the sockets have been activated in the ini file. -- Bastien Cat, the other other white meat I think that I messed up sending my last email, I apologize. Is the user that Apache is running under configured for the proper read write access to the socket file? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Oops, included in php.ini, not the Apache config. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP sockets enabled but socket_create() gives an error callto undefined function
I don't think the unix permission will cause a function undefined error. 於 2010年11月02日 01:08, crrr errr 提到: Yes, the http ( Apache user) has rl ( read permission) on the php file with sockets code in it. I think write access is unnecessary for Apache user. On Mon, Nov 1, 2010 at 12:50 PM, Nicholas Kelln...@monkeyknight.comwrote: On Nov 1, 2010, at 11:44 AM, crrr errr wrote: Yes, the phpinfo() shows that sockets are enabled in both machines. On Mon, Nov 1, 2010 at 12:43 PM, Bastien Koertphps...@gmail.com wrote: On Mon, Nov 1, 2010 at 12:40 PM, crrr e.suy...@gmail.com wrote: Hello, I was trying to create a socket connection from a Solaris machine to a Red Hat machine to get the PATH in Red Hat machine remotely on Solaris machine and display it to the user. We have a PHP 5.1.6 installation on a Linux server (Apache) and PHP 5.2.6. on a Unix(Solaris) server(Apache) . The PHP version on Solaris is compiled with --enable sockets and phpinfo() displays that the sockets are enabled. In spite of this we get the following error when using this piece of code from the Solaris machine. The error: PHP Fatal error: Call to undefined function socket_create() in /XXX/ 5server.php http://cad.njit.edu/u/d/x/dx8/public_html/clunk/swsearch5server.php on line 21 The code; ?php set_time_limit(0); //ip of the server $addr = 'xxx.xxx.xxx.xxx'; //port of the server $port = 2xxx; //create a socket $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); /* This is line no 21 in the code. i have ommitted a few header comments */ //bind this socket with the above ip and port $ret = socket_bind($sock, $addr, $port); do { $ret = socket_listen($sock, 10); $msgSock = socket_accept($sock); $buf = socket_read($msgSock, 1024); Please let me know if you need any further details I might have missed. Thank you. Suyash Ramineni check phpinfo() to see if the sockets have been activated in the ini file. -- Bastien Cat, the other other white meat I think that I messed up sending my last email, I apologize. Is the user that Apache is running under configured for the proper read write access to the socket file? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP sockets enabled but socket_create() gives an error callto undefined function
On Nov 1, 2010, at 12:36 PM, rek wrote: I don't think the unix permission will cause a function undefined error. 於 2010年11月02日 01:08, crrr errr 提到: Yes, the http ( Apache user) has rl ( read permission) on the php file with sockets code in it. I think write access is unnecessary for Apache user. On Mon, Nov 1, 2010 at 12:50 PM, Nicholas Kelln...@monkeyknight.comwrote: On Nov 1, 2010, at 11:44 AM, crrr errr wrote: Yes, the phpinfo() shows that sockets are enabled in both machines. On Mon, Nov 1, 2010 at 12:43 PM, Bastien Koertphps...@gmail.com wrote: On Mon, Nov 1, 2010 at 12:40 PM, crrr e.suy...@gmail.com wrote: Hello, I was trying to create a socket connection from a Solaris machine to a Red Hat machine to get the PATH in Red Hat machine remotely on Solaris machine and display it to the user. We have a PHP 5.1.6 installation on a Linux server (Apache) and PHP 5.2.6. on a Unix(Solaris) server(Apache) . The PHP version on Solaris is compiled with --enable sockets and phpinfo() displays that the sockets are enabled. In spite of this we get the following error when using this piece of code from the Solaris machine. The error: PHP Fatal error: Call to undefined function socket_create() in /XXX/ 5server.php http://cad.njit.edu/u/d/x/dx8/public_html/clunk/swsearch5server.php on line 21 The code; ?php set_time_limit(0); //ip of the server $addr = 'xxx.xxx.xxx.xxx'; //port of the server $port = 2xxx; //create a socket $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); /* This is line no 21 in the code. i have ommitted a few header comments */ //bind this socket with the above ip and port $ret = socket_bind($sock, $addr, $port); do { $ret = socket_listen($sock, 10); $msgSock = socket_accept($sock); $buf = socket_read($msgSock, 1024); Please let me know if you need any further details I might have missed. Thank you. Suyash Ramineni check phpinfo() to see if the sockets have been activated in the ini file. -- Bastien Cat, the other other white meat I think that I messed up sending my last email, I apologize. Is the user that Apache is running under configured for the proper read write access to the socket file? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php You're absolutely right. I was wrong. If the permissions weren't correct he would have gotten a Operation not permitted warning. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP sockets enabled but socket_create() gives an error call to undefined function
No, sockets.so in not included in any of the machines php.ini file. However, I found that Linux machine's php.ini doesn't include sockets.so and sockets work fine on it but don't work on the Solaris machine. Is it required to be included only in Solaris? On Mon, Nov 1, 2010 at 1:41 PM, Nicholas Kell n...@monkeyknight.com wrote: On Nov 1, 2010, at 12:08 PM, crrr errr wrote: Yes, the http ( Apache user) has rl ( read permission) on the php file with sockets code in it. I think write access is unnecessary for Apache user. On Mon, Nov 1, 2010 at 12:50 PM, Nicholas Kell n...@monkeyknight.com wrote: On Nov 1, 2010, at 11:44 AM, crrr errr wrote: Yes, the phpinfo() shows that sockets are enabled in both machines. On Mon, Nov 1, 2010 at 12:43 PM, Bastien Koert phps...@gmail.com wrote: On Mon, Nov 1, 2010 at 12:40 PM, crrr errr r.suy...@gmail.com wrote: Hello, I was trying to create a socket connection from a Solaris machine to a Red Hat machine to get the PATH in Red Hat machine remotely on Solaris machine and display it to the user. We have a PHP 5.1.6 installation on a Linux server (Apache) and PHP 5.2.6. on a Unix(Solaris) server(Apache) . The PHP version on Solaris is compiled with --enable sockets and phpinfo() displays that the sockets are enabled. In spite of this we get the following error when using this piece of code from the Solaris machine. The error: PHP Fatal error: Call to undefined function socket_create() in /XXX/ 5server.php http://cad.njit.edu/u/d/x/dx8/public_html/clunk/swsearch5server.php on line 21 The code; ?php set_time_limit(0); //ip of the server $addr = 'xxx.xxx.xxx.xxx'; //port of the server $port = 2xxx; //create a socket $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); /* This is line no 21 in the code. i have ommitted a few header comments */ //bind this socket with the above ip and port $ret = socket_bind($sock, $addr, $port); do { $ret = socket_listen($sock, 10); $msgSock = socket_accept($sock); $buf = socket_read($msgSock, 1024); Please let me know if you need any further details I might have missed. Thank you. Suyash Ramineni check phpinfo() to see if the sockets have been activated in the ini file. -- Bastien Cat, the other other white meat I think that I messed up sending my last email, I apologize. Is the user that Apache is running under configured for the proper read write access to the socket file? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Oops, included in php.ini, not the Apache config. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP sockets enabled but socket_create() gives an error call to undefined function
On Nov 1, 2010, at 1:12 PM, Suyash R wrote: No, sockets.so in not included in any of the machines php.ini file. However, I found that Linux machine's php.ini doesn't include sockets.so and sockets work fine on it but don't work on the Solaris machine. Is it required to be included only in Solaris? On Mon, Nov 1, 2010 at 1:41 PM, Nicholas Kell n...@monkeyknight.com wrote: On Nov 1, 2010, at 12:08 PM, crrr errr wrote: Yes, the http ( Apache user) has rl ( read permission) on the php file with sockets code in it. I think write access is unnecessary for Apache user. On Mon, Nov 1, 2010 at 12:50 PM, Nicholas Kell n...@monkeyknight.comwrote: On Nov 1, 2010, at 11:44 AM, crrr errr wrote: Yes, the phpinfo() shows that sockets are enabled in both machines. On Mon, Nov 1, 2010 at 12:43 PM, Bastien Koert phps...@gmail.com wrote: On Mon, Nov 1, 2010 at 12:40 PM, crrr errr r.suy...@gmail.com wrote: Hello, I was trying to create a socket connection from a Solaris machine to a Red Hat machine to get the PATH in Red Hat machine remotely on Solaris machine and display it to the user. We have a PHP 5.1.6 installation on a Linux server (Apache) and PHP 5.2.6. on a Unix(Solaris) server(Apache) . The PHP version on Solaris is compiled with --enable sockets and phpinfo() displays that the sockets are enabled. In spite of this we get the following error when using this piece of code from the Solaris machine. The error: PHP Fatal error: Call to undefined function socket_create() in /XXX/ 5server.php http://cad.njit.edu/u/d/x/dx8/public_html/clunk/swsearch5server.php on line 21 The code; ?php set_time_limit(0); //ip of the server $addr = 'xxx.xxx.xxx.xxx'; //port of the server $port = 2xxx; //create a socket $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); /* This is line no 21 in the code. i have ommitted a few header comments */ //bind this socket with the above ip and port $ret = socket_bind($sock, $addr, $port); do { $ret = socket_listen($sock, 10); $msgSock = socket_accept($sock); $buf = socket_read($msgSock, 1024); Please let me know if you need any further details I might have missed. Thank you. Suyash Ramineni check phpinfo() to see if the sockets have been activated in the ini file. -- Bastien Cat, the other other white meat I think that I messed up sending my last email, I apologize. Is the user that Apache is running under configured for the proper read write access to the socket file? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Oops, included in php.ini, not the Apache config. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Since you complied with --enable-sockets, you shouldn't even need sockets.so to be dynamically loaded. But at this point, it is something that I would try anyway. Add: extension=sockets.so in your php.ini file just to see if it brings the function to light. Your Linux installs I am sure were compiled with it in it. Especially if it is a dist package. The absence of the function is telling me that PHP is not compiled with --enable-sockets. If it was compiled in properly, you would be getting different errors. I am not saying that you didn't do it. Something may have happened in the process. By adding the sockets.so, you are adding the extension dynamically, incase you were mistaken by the compile or incase there was some sort of anomaly that the rest of PHP compiled but the sockets section was botched. Solaris is (I guess) known to be lacking when it comes to C compilers (at least according to the Unix geeks that I sit next to at work). But it seems to me that it would all have failed or it would have all worked.
Re: [PHP] Sockets (reading)
On Wed, Aug 26, 2009 at 5:36 PM, Philip Thompson philthath...@gmail.comwrote: On Aug 26, 2009, at 2:47 PM, Bob McConnell wrote: From: Philip Thompson On Aug 26, 2009, at 11:56 AM, Bob McConnell wrote: From: Philip Thompson During a socket read, why would all the requested number of bytes not get sent? For example, I request 1000 bytes: ?php $data = @socket_read ($socket, 2048, PHP_BINARY_READ); ? This is actually in a loop, so I can get all the data if split up. So, for example, here's how the data split up in 3 iterations (for 1000 bytes): 650 bytes 200 bytes 150 bytes But if I can accept up to 2048 bytes per socket read, why would it not pull all 1000 bytes initially in 1 step? Any thoughts on this would be greatly appreciated! Because that's the way TCP/IP works, by design. TCP is a stream protocol. It guarantees all of the bytes written to one end of the pipe will come out the other end in the same order, but not necessarily in the same groupings. There are a number of buffers along the way that might split them up, as well as limits on packet sizes in the various networks it passed through. So you get what is available in the last buffer when a timer expires, no more, and no less. If you have serialized data that needs to be grouped in specific blocks, your application will need to keep track of those blocks, reassembling or splitting the streamed data as necessary. You could use UDP which does guarantee that packets will be kept together, but that protocol doesn't guarantee delivery. Thank you for your input. Is it guaranteed that at least 1 byte will be sent each time? For example, if I know the data length... ?php $input = ''; for ($i=0; $i$dataLength; $i++) { // Read 1 byte at a time if (($data = @socket_read ($socket, 1, PHP_BINARY_READ)) !== false) { $input .= $data; } } return $input; ? Or is this a completely unreasonable and unnecessary way to get the data? While I have written a lot of code to manage sockets over the years, and coded a UDP/IP stack, I have never done it in PHP. And unfortunately, I don't have time to experiment right now. My boss is waiting for the next product release from me. Getting one byte at a time is somewhat wasteful, as it requires more system calls than necessary. That's a lot of wasted overhead. Whether you always get one or more bytes depends on a number of factors, including whether the calls PHP uses are blocking or non-blocking, plus there may be ways to switch the socket back and forth. Have you tried doing a Google search on the group of PHP functions you expect to use. That should come up with some sample code to look at. Bob McConnell I agree that one byte at a time is wasteful. I'm sure others haven't implemented something along these lines, but I wrote a much more efficient way to make sure I grab all the data of a known length... ?php function readSocketForDataLength ($socket, $len) { $offset = 0; $socketData = ''; while ($offset $len) { if (($data = @socket_read ($socket, $len - $offset, PHP_BINARY_READ)) === false) { return false; } $offset += strlen ($data); $socketData .= $data; } return $socketData; } ? If not all the data is obtained on a read, it will loop until the amount of data is the same as the length requested. This is working quite well. Thanks Bob and the others! ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php socket related: Does this solution work on both, blocking and non-blocking sockets ? And what about different read method? solution related: Does strlen works fine with binary data? Does this snippet work for sending/receiving multibytes strings? -- Martin Scotta
[PHP] Sockets (reading)
Hi. During a socket read, why would all the requested number of bytes not get sent? For example, I request 1000 bytes: ?php $data = @socket_read ($socket, 2048, PHP_BINARY_READ); ? This is actually in a loop, so I can get all the data if split up. So, for example, here's how the data split up in 3 iterations (for 1000 bytes): 650 bytes 200 bytes 150 bytes But if I can accept up to 2048 bytes per socket read, why would it not pull all 1000 bytes initially in 1 step? Any thoughts on this would be greatly appreciated! Thanks, ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sockets (reading)
Philip Thompson wrote: Hi. During a socket read, why would all the requested number of bytes not get sent? For example, I request 1000 bytes: ?php $data = @socket_read ($socket, 2048, PHP_BINARY_READ); ? This is actually in a loop, so I can get all the data if split up. So, for example, here's how the data split up in 3 iterations (for 1000 bytes): 650 bytes 200 bytes 150 bytes But if I can accept up to 2048 bytes per socket read, why would it not pull all 1000 bytes initially in 1 step? Any thoughts on this would be greatly appreciated! Thanks, ~Philip Is it possible that you are receiving a \r, \n, or \0 and that is stopping the input? Check the Parameters the second argument for Length options. http://us3.php.net/socket_read Here is a shortened version of a script that I use to do something similar. ?php error_reporting(E_ALL); ini_set('display_errors', 'On'); // Set time limit to indefinite execution set_time_limit(0); // Set the ip and port we will listen on define('LISTEN_IP', 'your IP address'); // IP to listin on define('LISTEN_PORT', port); // Port number define('PACKET_SIZE', 512); // 512 bytes define('SOCKET_TIMOUT', 2);// Seconds /* Open a server socket to port 1234 on localhost */ if ( $socket = @stream_socket_server('udp://'.LISTEN_IP.':'.LISTEN_PORT, $errno, $errstr, STREAM_SERVER_BIND) ) { while ( true ) { $buff = stream_socket_recvfrom($socket, PACKET_SIZE, 0, $remote_ip); if ( !empty($buff) ) { print('Received Data: '.PHP_EOL); print('Do something with it...'.PHP_EOL); } else { print('Empty String'.PHP_EOL); } } fclose($socket); } else { print([{$errno}] {$error}.PHP_EOL); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Sockets (reading)
From: Philip Thompson During a socket read, why would all the requested number of bytes not get sent? For example, I request 1000 bytes: ?php $data = @socket_read ($socket, 2048, PHP_BINARY_READ); ? This is actually in a loop, so I can get all the data if split up. So, for example, here's how the data split up in 3 iterations (for 1000 bytes): 650 bytes 200 bytes 150 bytes But if I can accept up to 2048 bytes per socket read, why would it not pull all 1000 bytes initially in 1 step? Any thoughts on this would be greatly appreciated! Because that's the way TCP/IP works, by design. TCP is a stream protocol. It guarantees all of the bytes written to one end of the pipe will come out the other end in the same order, but not necessarily in the same groupings. There are a number of buffers along the way that might split them up, as well as limits on packet sizes in the various networks it passed through. So you get what is available in the last buffer when a timer expires, no more, and no less. If you have serialized data that needs to be grouped in specific blocks, your application will need to keep track of those blocks, reassembling or splitting the streamed data as necessary. You could use UDP which does guarantee that packets will be kept together, but that protocol doesn't guarantee delivery. Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sockets (reading)
On Aug 26, 2009, at 11:56 AM, Bob McConnell wrote: From: Philip Thompson During a socket read, why would all the requested number of bytes not get sent? For example, I request 1000 bytes: ?php $data = @socket_read ($socket, 2048, PHP_BINARY_READ); ? This is actually in a loop, so I can get all the data if split up. So, for example, here's how the data split up in 3 iterations (for 1000 bytes): 650 bytes 200 bytes 150 bytes But if I can accept up to 2048 bytes per socket read, why would it not pull all 1000 bytes initially in 1 step? Any thoughts on this would be greatly appreciated! Because that's the way TCP/IP works, by design. TCP is a stream protocol. It guarantees all of the bytes written to one end of the pipe will come out the other end in the same order, but not necessarily in the same groupings. There are a number of buffers along the way that might split them up, as well as limits on packet sizes in the various networks it passed through. So you get what is available in the last buffer when a timer expires, no more, and no less. If you have serialized data that needs to be grouped in specific blocks, your application will need to keep track of those blocks, reassembling or splitting the streamed data as necessary. You could use UDP which does guarantee that packets will be kept together, but that protocol doesn't guarantee delivery. Bob McConnell Thank you for your input. Is it guaranteed that at least 1 byte will be sent each time? For example, if I know the data length... ?php $input = ''; for ($i=0; $i$dataLength; $i++) { // Read 1 byte at a time if (($data = @socket_read ($socket, 1, PHP_BINARY_READ)) !== false) { $input .= $data; } } return $input; ? Or is this a completely unreasonable and unnecessary way to get the data? Thanks, ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sockets (reading)
Bob McConnell wrote: From: Philip Thompson During a socket read, why would all the requested number of bytes not get sent? For example, I request 1000 bytes: ?php $data = @socket_read ($socket, 2048, PHP_BINARY_READ); ? This is actually in a loop, so I can get all the data if split up. So, for example, here's how the data split up in 3 iterations (for 1000 bytes): 650 bytes 200 bytes 150 bytes But if I can accept up to 2048 bytes per socket read, why would it not pull all 1000 bytes initially in 1 step? Any thoughts on this would be greatly appreciated! Because that's the way TCP/IP works, by design. TCP is a stream protocol. It guarantees all of the bytes written to one end of the pipe will come out the other end in the same order, but not necessarily in the same groupings. There are a number of buffers along the way that might split them up, as well as limits on packet sizes in the various networks it passed through. So you get what is available in the last buffer when a timer expires, no more, and no less. If you have serialized data that needs to be grouped in specific blocks, your application will need to keep track of those blocks, reassembling or splitting the streamed data as necessary. You could use UDP which does guarantee that packets will be kept together, but that protocol doesn't guarantee delivery. I'm not sure this has much to do with the OP's problem, but this part is backwards. TCP is connection oriented and tracks segments by sequence number for each connection. This enables the stack to pass the data in order to the higher layers. UDP is connectionless and has no way to determine what datagram was sent before the other one, so it is up to the higher layers to reassemble. As for IP in general, if packets need to be fragmented along the way by a router in order to fit the MTU of a different network, then the IP stack on the receiving end will reassemble the fragments based upon information that the router injects into the fragments. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Sockets (reading)
From: Shawn McKenzie Bob McConnell wrote: From: Philip Thompson During a socket read, why would all the requested number of bytes not get sent? For example, I request 1000 bytes: ?php $data = @socket_read ($socket, 2048, PHP_BINARY_READ); ? This is actually in a loop, so I can get all the data if split up. So, for example, here's how the data split up in 3 iterations (for 1000 bytes): 650 bytes 200 bytes 150 bytes But if I can accept up to 2048 bytes per socket read, why would it not pull all 1000 bytes initially in 1 step? Any thoughts on this would be greatly appreciated! Because that's the way TCP/IP works, by design. TCP is a stream protocol. It guarantees all of the bytes written to one end of the pipe will come out the other end in the same order, but not necessarily in the same groupings. There are a number of buffers along the way that might split them up, as well as limits on packet sizes in the various networks it passed through. So you get what is available in the last buffer when a timer expires, no more, and no less. If you have serialized data that needs to be grouped in specific blocks, your application will need to keep track of those blocks, reassembling or splitting the streamed data as necessary. You could use UDP which does guarantee that packets will be kept together, but that protocol doesn't guarantee delivery. I'm not sure this has much to do with the OP's problem, but this part is backwards. TCP is connection oriented and tracks segments by sequence number for each connection. This enables the stack to pass the data in order to the higher layers. UDP is connectionless and has no way to determine what datagram was sent before the other one, so it is up to the higher layers to reassemble. As for IP in general, if packets need to be fragmented along the way by a router in order to fit the MTU of a different network, then the IP stack on the receiving end will reassemble the fragments based upon information that the router injects into the fragments. Shawn, You're looking at it inside out. Yes, the individual packets are tracked by the stack, to make sure they arrive in the correct order. But the size and fragmentation of those packets have no relationship at all to any data structure the application layer may imply. They simply implement a communications stream to reliably move octets from one point to another. If the application needs structure, it has to manage that for itself. For UDP, if you write a 32 byte packet, the matching read will get a 32 byte packet, if it arrived at the receiving stack. Missed data detection and retry requests are left up to the application. Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Sockets (reading)
From: Philip Thompson On Aug 26, 2009, at 11:56 AM, Bob McConnell wrote: From: Philip Thompson During a socket read, why would all the requested number of bytes not get sent? For example, I request 1000 bytes: ?php $data = @socket_read ($socket, 2048, PHP_BINARY_READ); ? This is actually in a loop, so I can get all the data if split up. So, for example, here's how the data split up in 3 iterations (for 1000 bytes): 650 bytes 200 bytes 150 bytes But if I can accept up to 2048 bytes per socket read, why would it not pull all 1000 bytes initially in 1 step? Any thoughts on this would be greatly appreciated! Because that's the way TCP/IP works, by design. TCP is a stream protocol. It guarantees all of the bytes written to one end of the pipe will come out the other end in the same order, but not necessarily in the same groupings. There are a number of buffers along the way that might split them up, as well as limits on packet sizes in the various networks it passed through. So you get what is available in the last buffer when a timer expires, no more, and no less. If you have serialized data that needs to be grouped in specific blocks, your application will need to keep track of those blocks, reassembling or splitting the streamed data as necessary. You could use UDP which does guarantee that packets will be kept together, but that protocol doesn't guarantee delivery. Thank you for your input. Is it guaranteed that at least 1 byte will be sent each time? For example, if I know the data length... ?php $input = ''; for ($i=0; $i$dataLength; $i++) { // Read 1 byte at a time if (($data = @socket_read ($socket, 1, PHP_BINARY_READ)) !== false) { $input .= $data; } } return $input; ? Or is this a completely unreasonable and unnecessary way to get the data? While I have written a lot of code to manage sockets over the years, and coded a UDP/IP stack, I have never done it in PHP. And unfortunately, I don't have time to experiment right now. My boss is waiting for the next product release from me. Getting one byte at a time is somewhat wasteful, as it requires more system calls than necessary. That's a lot of wasted overhead. Whether you always get one or more bytes depends on a number of factors, including whether the calls PHP uses are blocking or non-blocking, plus there may be ways to switch the socket back and forth. Have you tried doing a Google search on the group of PHP functions you expect to use. That should come up with some sample code to look at. Bob McConnell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sockets (reading)
On Aug 26, 2009, at 2:47 PM, Bob McConnell wrote: From: Philip Thompson On Aug 26, 2009, at 11:56 AM, Bob McConnell wrote: From: Philip Thompson During a socket read, why would all the requested number of bytes not get sent? For example, I request 1000 bytes: ?php $data = @socket_read ($socket, 2048, PHP_BINARY_READ); ? This is actually in a loop, so I can get all the data if split up. So, for example, here's how the data split up in 3 iterations (for 1000 bytes): 650 bytes 200 bytes 150 bytes But if I can accept up to 2048 bytes per socket read, why would it not pull all 1000 bytes initially in 1 step? Any thoughts on this would be greatly appreciated! Because that's the way TCP/IP works, by design. TCP is a stream protocol. It guarantees all of the bytes written to one end of the pipe will come out the other end in the same order, but not necessarily in the same groupings. There are a number of buffers along the way that might split them up, as well as limits on packet sizes in the various networks it passed through. So you get what is available in the last buffer when a timer expires, no more, and no less. If you have serialized data that needs to be grouped in specific blocks, your application will need to keep track of those blocks, reassembling or splitting the streamed data as necessary. You could use UDP which does guarantee that packets will be kept together, but that protocol doesn't guarantee delivery. Thank you for your input. Is it guaranteed that at least 1 byte will be sent each time? For example, if I know the data length... ?php $input = ''; for ($i=0; $i$dataLength; $i++) { // Read 1 byte at a time if (($data = @socket_read ($socket, 1, PHP_BINARY_READ)) !== false) { $input .= $data; } } return $input; ? Or is this a completely unreasonable and unnecessary way to get the data? While I have written a lot of code to manage sockets over the years, and coded a UDP/IP stack, I have never done it in PHP. And unfortunately, I don't have time to experiment right now. My boss is waiting for the next product release from me. Getting one byte at a time is somewhat wasteful, as it requires more system calls than necessary. That's a lot of wasted overhead. Whether you always get one or more bytes depends on a number of factors, including whether the calls PHP uses are blocking or non-blocking, plus there may be ways to switch the socket back and forth. Have you tried doing a Google search on the group of PHP functions you expect to use. That should come up with some sample code to look at. Bob McConnell I agree that one byte at a time is wasteful. I'm sure others haven't implemented something along these lines, but I wrote a much more efficient way to make sure I grab all the data of a known length... ?php function readSocketForDataLength ($socket, $len) { $offset = 0; $socketData = ''; while ($offset $len) { if (($data = @socket_read ($socket, $len - $offset, PHP_BINARY_READ)) === false) { return false; } $offset += strlen ($data); $socketData .= $data; } return $socketData; } ? If not all the data is obtained on a read, it will loop until the amount of data is the same as the length requested. This is working quite well. Thanks Bob and the others! ~Philip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php sockets
well i mean even if we would not consider that particular piece of code as an example of the code that i have issues with im still rather interesting if theres some different between the socket model used by say, c++(winsock in my case) and the sockets used in php because when made a simple c++ script (winsock based) which just echoes what its gotten from a client i still get a problem which looks like this: when php client connects to the serv, the server then gets into an endnless loop loading the cpu almost up to max . Although i get a message from it in the php script (which server was supposed to send when the client connects) but the server itself doesnt work correctly for some reason, and thats what im curious about. Again, when i rewrote the whole functionality of the client in c++ it worked just as it was supposed to, while being written in php(client part) it all messes up. Nathan Nobbe [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] figured id top-post on this one, since the original message was so long.. i recommend debugging with a tool like wireshark. that way you can see whats in the packets going over the wire and hopefully it will lead to a solution. -nathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php sockets
vixle wrote: well i mean even if we would not consider that particular piece of code as an example of the code that i have issues with im still rather interesting if theres some different between the socket model used by say, c++(winsock in my case) and the sockets used in php because when made a simple c++ script (winsock based) which just echoes what its gotten from a client i still get a problem which looks like this: when php client connects to the serv, the server then gets into an endnless loop loading the cpu almost up to max . Although i get a message from it in the php script (which server was supposed to send when the client connects) but the server itself doesnt work correctly for some reason, and thats what im curious about. Again, when i rewrote the whole functionality of the client in c++ it worked just as it was supposed to, while being written in php(client part) it all messes up. Nathan Nobbe [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] figured id top-post on this one, since the original message was so long.. i recommend debugging with a tool like wireshark. that way you can see whats in the packets going over the wire and hopefully it will lead to a solution. -nathan well, since it is the php version, and this is a php list, why don't you show us your complete PHP source code instead of you C++ source. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php sockets
With any code doing a basic socket functionality, the code that i gave in the original post is suppossed to connect to a deamon, and get a message from it , instead it makes the deamon go crazy in the sense that it starts endless looping and loads the system resources up to max. Jim Lucas [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] well, since it is the php version, and this is a php list, why don't you show us your complete PHP source code instead of you C++ source. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: php sockets
figured id top-post on this one, since the original message was so long.. i recommend debugging with a tool like wireshark. that way you can see whats in the packets going over the wire and hopefully it will lead to a solution. -nathan On Dec 19, 2007 12:54 AM, vixle [EMAIL PROTECTED] wrote: this code doesn't interact with php client while with c++ based one it works just fine. .anybody? #include stdio.h #include winsock2.h #include iostream #include process.h using namespace std; int i = 0; int ar = 0; const int is = 50; SOCKET stack[is]; void clientserve(void* ws) { SOCKET wsocket = *(SOCKET*)ws; int fgotused = 0; char sendbuf[70]; char recvbuf[70]; int scnt = 0; ar++; int id = ar; while(scnt = ar) { if(stack[scnt] == 0) { stack[scnt] = wsocket; id = scnt; fgotused = 1; scnt = 0; break; } scnt++; } if(fgotused == 0) stack[id] = wsocket; send(stack[id], Server message: You are now successfuly connected., 70, 0 ); while(1) { scnt = 0; if(recv(wsocket, recvbuf, 70, 0 ) == SOCKET_ERROR) { if(WSAGetLastError() == WSAECONNRESET) { i--; stack[id] = 0; cout Client Disconnected. endl; cout Clients connected: i endl; closesocket(wsocket); return; } } if(recvbuf) { cout recvbuf endl; while(scnt = ar) { if(scnt != id) send(stack[scnt], recvbuf, 70, 0); scnt++; } recvbuf = null; } } } void main() { WSADATA wsaData; int iResult = WSAStartup(MAKEWORD(2,2),wsaData); if (iResult != NO_ERROR) printf(Error at WSAStartup()\n); SOCKET m_socket; m_socket = socket (AF_INET, SOCK_STREAM, 0); if (m_socket == INVALID_SOCKET) { printf(Error at socket(): %ld\n, WSAGetLastError()); WSACleanup(); return; } sockaddr_in service; service.sin_family = AF_INET; service.sin_addr.s_addr = inet_addr(127.0.0.1); service.sin_port = htons(27015); if (bind(m_socket,(SOCKADDR*)service, sizeof(service)) == SOCKET_ERROR) { printf(bind() failed.\n); closesocket(m_socket); return; } if (listen(m_socket, 700) == SOCKET_ERROR) printf( Error listening on socket.\n); SOCKET AcceptSocket; printf(Waiting for a client to connect...\n); while (AcceptSocket = accept(m_socket, NULL, NULL)) { i++; cout Client Connected. endl; cout Clients connected: i endl; _beginthread(clientserve, 0, (void*)AcceptSocket); } } vixle [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] ?php /* Get the port for the WWW service. */ //$service_port = getservbyname('www', 'tcp'); /* Get the IP address for the target host. */ //$address = gethostbyname('www.example.com'); /* Create a TCP/IP socket. */ $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); //echo Attempting to connect to '$address' on port '$service_port'...; $result = socket_connect($socket, 127.0.0.1, 27015); socket_RECV($socket, $read, 300, null); echo $read; socket_close($socket); ? i have a daemon running on that port that sends a message when it's got a client connected but the script above doesn't output anything it just loads my cpu up to 100 percent and thats it then it basically stops working. While i need it to display the messages sent by server(daemon) to the user running the script has anyone got any idea why it rejects to work? (yeah the daemon is written in c++ if that matters) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php sockets
this code doesn't interact with with php client while with c++ based one it works just fine. .anybody? #include stdio.h #include winsock2.h #include iostream #include process.h using namespace std; int i = 0; int ar = 0; const int is = 50; SOCKET stack[is]; void clientserve(void* ws) { SOCKET wsocket = *(SOCKET*)ws; int fgotused = 0; char sendbuf[70]; char recvbuf[70]; int scnt = 0; ar++; int id = ar; while(scnt = ar) { if(stack[scnt] == 0) { stack[scnt] = wsocket; id = scnt; fgotused = 1; scnt = 0; break; } scnt++; } if(fgotused == 0) stack[id] = wsocket; send(stack[id], Server message: You are now successfuly connected., 70, 0 ); while(1) { scnt = 0; if(recv(wsocket, recvbuf, 70, 0 ) == SOCKET_ERROR) { if(WSAGetLastError() == WSAECONNRESET) { i--; stack[id] = 0; cout Client Disconnected. endl; cout Clients connected: i endl; closesocket(wsocket); return; } } if(recvbuf) { cout recvbuf endl; while(scnt = ar) { if(scnt != id) send(stack[scnt], recvbuf, 70, 0); scnt++; } recvbuf = null; } } } void main() { WSADATA wsaData; int iResult = WSAStartup(MAKEWORD(2,2),wsaData); if (iResult != NO_ERROR) printf(Error at WSAStartup()\n); SOCKET m_socket; m_socket = socket (AF_INET, SOCK_STREAM, 0); if (m_socket == INVALID_SOCKET) { printf(Error at socket(): %ld\n, WSAGetLastError()); WSACleanup(); return; } sockaddr_in service; service.sin_family = AF_INET; service.sin_addr.s_addr = inet_addr(127.0.0.1); service.sin_port = htons(27015); if (bind(m_socket,(SOCKADDR*)service, sizeof(service)) == SOCKET_ERROR) { printf(bind() failed.\n); closesocket(m_socket); return; } if (listen(m_socket, 700) == SOCKET_ERROR) printf( Error listening on socket.\n); SOCKET AcceptSocket; printf(Waiting for a client to connect...\n); while (AcceptSocket = accept(m_socket, NULL, NULL)) { i++; cout Client Connected. endl; cout Clients connected: i endl; _beginthread(clientserve, 0, (void*)AcceptSocket); } } vixle [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] ?php /* Get the port for the WWW service. */ //$service_port = getservbyname('www', 'tcp'); /* Get the IP address for the target host. */ //$address = gethostbyname('www.example.com'); /* Create a TCP/IP socket. */ $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); //echo Attempting to connect to '$address' on port '$service_port'...; $result = socket_connect($socket, 127.0.0.1, 27015); socket_RECV($socket, $read, 300, null); echo $read; socket_close($socket); ? i have a daemon running on that port that sends a message when it's got a client connected but the script above doesn't output anything it just loads my cpu up to 100 percent and thats it then it basically stops working. While i need it to display the messages sent by server(daemon) to the user running the script has anyone got any idea why it rejects to work? (yeah the daemon is written in c++ if that matters) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php sockets
this code doesn't interact with php client while with c++ based one it works just fine. .anybody? #include stdio.h #include winsock2.h #include iostream #include process.h using namespace std; int i = 0; int ar = 0; const int is = 50; SOCKET stack[is]; void clientserve(void* ws) { SOCKET wsocket = *(SOCKET*)ws; int fgotused = 0; char sendbuf[70]; char recvbuf[70]; int scnt = 0; ar++; int id = ar; while(scnt = ar) { if(stack[scnt] == 0) { stack[scnt] = wsocket; id = scnt; fgotused = 1; scnt = 0; break; } scnt++; } if(fgotused == 0) stack[id] = wsocket; send(stack[id], Server message: You are now successfuly connected., 70, 0 ); while(1) { scnt = 0; if(recv(wsocket, recvbuf, 70, 0 ) == SOCKET_ERROR) { if(WSAGetLastError() == WSAECONNRESET) { i--; stack[id] = 0; cout Client Disconnected. endl; cout Clients connected: i endl; closesocket(wsocket); return; } } if(recvbuf) { cout recvbuf endl; while(scnt = ar) { if(scnt != id) send(stack[scnt], recvbuf, 70, 0); scnt++; } recvbuf = null; } } } void main() { WSADATA wsaData; int iResult = WSAStartup(MAKEWORD(2,2),wsaData); if (iResult != NO_ERROR) printf(Error at WSAStartup()\n); SOCKET m_socket; m_socket = socket (AF_INET, SOCK_STREAM, 0); if (m_socket == INVALID_SOCKET) { printf(Error at socket(): %ld\n, WSAGetLastError()); WSACleanup(); return; } sockaddr_in service; service.sin_family = AF_INET; service.sin_addr.s_addr = inet_addr(127.0.0.1); service.sin_port = htons(27015); if (bind(m_socket,(SOCKADDR*)service, sizeof(service)) == SOCKET_ERROR) { printf(bind() failed.\n); closesocket(m_socket); return; } if (listen(m_socket, 700) == SOCKET_ERROR) printf( Error listening on socket.\n); SOCKET AcceptSocket; printf(Waiting for a client to connect...\n); while (AcceptSocket = accept(m_socket, NULL, NULL)) { i++; cout Client Connected. endl; cout Clients connected: i endl; _beginthread(clientserve, 0, (void*)AcceptSocket); } } vixle [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] ?php /* Get the port for the WWW service. */ //$service_port = getservbyname('www', 'tcp'); /* Get the IP address for the target host. */ //$address = gethostbyname('www.example.com'); /* Create a TCP/IP socket. */ $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); //echo Attempting to connect to '$address' on port '$service_port'...; $result = socket_connect($socket, 127.0.0.1, 27015); socket_RECV($socket, $read, 300, null); echo $read; socket_close($socket); ? i have a daemon running on that port that sends a message when it's got a client connected but the script above doesn't output anything it just loads my cpu up to 100 percent and thats it then it basically stops working. While i need it to display the messages sent by server(daemon) to the user running the script has anyone got any idea why it rejects to work? (yeah the daemon is written in c++ if that matters) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php sockets
?php /* Get the port for the WWW service. */ //$service_port = getservbyname('www', 'tcp'); /* Get the IP address for the target host. */ //$address = gethostbyname('www.example.com'); /* Create a TCP/IP socket. */ $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); //echo Attempting to connect to '$address' on port '$service_port'...; $result = socket_connect($socket, 127.0.0.1, 27015); socket_RECV($socket, $read, 300, null); echo $read; socket_close($socket); ? i have a daemon running on that port that sends a message when it's got a client connected but the script above doesn't output anything it just loads my cpu up to 100 percent and thats it then it basically stops working. While i need it to display the messages sent by server(daemon) to the user running the script has anyone got any idea why it rejects to work? (yeah the daemon is written in c++ if that matters) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sockets as a module or a separate PHP CLI instance?
I need to do some socket work on a production machine that is constantly busy so I don't dare re-compile php. Anybody know if it's possible to load the socket functions dynamically, maybe as if they were in a module? Alternatively, would it be possible to compile PHP without apache and with sockets for command line use only? If I do that I would like to give the resulting object a different name than PHP because I do have some cmd line pgms running on the machine. Is that difficult? Tx, Paul W -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sockets as a module or a separate PHP CLI instance?
Am Mittwoch, 2. Mai 2007 13:29 schrieb [EMAIL PROTECTED]: I need to do some socket work on a production machine that is constantly busy so I don't dare re-compile php. Anybody know if it's possible to load the socket functions dynamically, maybe as if they were in a module? It's possible if it's possible to compile it as shared object. It is, as far as I know. --with-socket=shared There might be some obstacles with threaded servers. I am not sure. Alternatively, would it be possible to compile PHP without apache and with sockets for command line use only? --enable-cli Regards, Oliver -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sockets as a module or a separate PHP CLI instance?
Am Mittwoch, 2. Mai 2007 14:36 schrieb Oliver Block: --with-socket=shared Actually it should be --enable-sockets=shared Regards, Oliver -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sockets as a module or a separate PHP CLI instance?
On Wed, May 2, 2007 6:29 am, [EMAIL PROTECTED] wrote: I need to do some socket work on a production machine that is constantly busy so I don't dare re-compile php. Anybody know if it's possible to load the socket functions dynamically, maybe as if they were in a module? If you can do --with-sockets=shared, for the configure, you should end up with a sockets.so file that you can then use http://php.net/dl to load into your scripts that need sockets... At least, *some* extensions this works... Alternatively, would it be possible to compile PHP without apache and with sockets for command line use only? Definitely. Just compile it as CLI or CGI, without the --with-apxs or --with-apxs2 or whatever pulls in Apache. If I do that I would like to give the resulting object a different name than PHP because I do have some cmd line pgms running on the machine. Is that difficult? Then don't do 'make install' but just copy the bin/php over to /usr/local/bin/php-with-sockets Then you can do php-with-sockets -q whatever.php to run that one special PHP binary. Alternatively, you can download the PHP source to a whole new fresh directory, compile it for CLI, and then leave it there, and use: /path/to/php/src/php/bin/php -q whatever.php so that you are running the special php binary from that source directory instead of the usual one in /usr/local/bin (or wherever yours lives) I did that for a CVS version when I needed a patched PHP on a shared host, and it worked pretty well for a cron job. It would be kind of cumbersome for something you wanted to run by hand from the shell a lot, but for a set it and forget it cron job, it was fine for me. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sockets problem
Thanks for the answer. In the meantime I've managed to solve the problem be removing the pcntl_wait call. Actually I think this is a bug, because as I understand things pcntl_wait shouldn't block the main process, but I don't have experience with either sockets or Unix process, so I might be wrong. On 3/21/07, Richard Lynch [EMAIL PROTECTED] wrote: On Tue, March 20, 2007 8:27 am, Adrian Gheorghe wrote: I've sent a bug report earlier and it got marked as bogus, so I decided to ask here about a possible solution. You can see the bug report at http://bugs.php.net/bug.php?id=40864 Looks like a pretty cogent bug report to me... Perhaps Tony would like to see the same script in non-fork single-connection mode on the same server, to prove that the ports/firewalls/etc are not at fault. Or, perhaps, there's something inherently wrong with that script... I'd also suggest taking out the 'fork' business and just opening up two sockets in two scripts, to remove the pcntl (possible) red herring -- boil it down to absolute minimum. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sockets problem
Hello everyone, I've sent a bug report earlier and it got marked as bogus, so I decided to ask here about a possible solution. You can see the bug report at http://bugs.php.net/bug.php?id=40864 Thanks in advance, Adrian. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sockets problem
On Tue, March 20, 2007 8:27 am, Adrian Gheorghe wrote: I've sent a bug report earlier and it got marked as bogus, so I decided to ask here about a possible solution. You can see the bug report at http://bugs.php.net/bug.php?id=40864 Looks like a pretty cogent bug report to me... Perhaps Tony would like to see the same script in non-fork single-connection mode on the same server, to prove that the ports/firewalls/etc are not at fault. Or, perhaps, there's something inherently wrong with that script... I'd also suggest taking out the 'fork' business and just opening up two sockets in two scripts, to remove the pcntl (possible) red herring -- boil it down to absolute minimum. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Sockets - How to detect client disconnection?
How do I detect a disconnected client from a socket resource? In an infinite loop, I socket_read() every open resource that passes a socket_select(). As far as I know, the only way to detect if the client disconnected unexpectedly from their socket resource is when socket_read() returns FALSE (which, during my testing, produced the warning: An established connection was aborted by the software in your host machine.). However, socket_read() doesn't return FALSE on a disconnected client's socket resource until I first attempt to socket_write() to that resource. In brief pseudo code... socket_create(AF_INET, SOCK_STREAM, SOL_TCP) while (TRUE) foreach (resource where (false === socket_select($arrayofresources, NULL, NULL, 0, 0)) if (socket_read() === false) WON'T DETECT DISCONNECT UNTIL I FIRST socket_write() I appreciate any support you offer and thank you for your time. Best regards, -Tony _ Type your favorite song. Get a customized station. Try MSN Radio powered by Pandora. http://radio.msn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Sockets - How to detect client disconnection?
I used Process Control Functions in PHP and installed some signals to catch socket disconnection. My attempt to do this in loops were a harder way or i could not manage it. There must be some notes about this in archives or i can send some of my code so that you can have a look at them. Aras Koktas [EMAIL PROTECTED] Business Excellence Development Phi.dot Internet Systems -Original Message- From: Anthony Rasmussen [mailto:[EMAIL PROTECTED] Sent: Saturday, January 06, 2007 11:12 PM To: php-general@lists.php.net Subject: [PHP] PHP Sockets - How to detect client disconnection? How do I detect a disconnected client from a socket resource? In an infinite loop, I socket_read() every open resource that passes a socket_select(). As far as I know, the only way to detect if the client disconnected unexpectedly from their socket resource is when socket_read() returns FALSE (which, during my testing, produced the warning: An established connection was aborted by the software in your host machine.). However, socket_read() doesn't return FALSE on a disconnected client's socket resource until I first attempt to socket_write() to that resource. In brief pseudo code... socket_create(AF_INET, SOCK_STREAM, SOL_TCP) while (TRUE) foreach (resource where (false === socket_select($arrayofresources, NULL, NULL, 0, 0)) if (socket_read() === false) WON'T DETECT DISCONNECT UNTIL I FIRST socket_write() I appreciate any support you offer and thank you for your time. Best regards, -Tony _ Type your favorite song. Get a customized station. Try MSN Radio powered by Pandora. http://radio.msn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sockets and SOAP
Hi, I want to implement a client-server relationship between a PHP server application and another .NET client application. I want the connection to be kept alive, so I use the socket routine running till disconnecting. I also want to transfer the data between the server and client using SOAP envelopes. How can I send SOAP envelopes (requests responses) through the same socket? If it's not possible with PHP's SOAP library, is it possible with other SOAP library for PHP (such PEAR:SOAP)? -thanks, Eli -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sockets
On 7/12/05, daro [EMAIL PROTECTED] wrote: I don't know where should I put this script to be able to receive all datas and respond with proper strings. You would run the script as a shell script from the command line. On windows you can just save the code as a regular php script then start it up from a DOS prompt like: c:\PHP\php.exe -f yoursocketfile.php or if you are using a *nix setup run it just as it is, making sure the first line points to your php binary, for example mine is /usr/bin/php. Chmod it so it's executable. -- Greg Donald Zend Certified Engineer MySQL Core Certification http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sockets
On Tue, 2005-07-12 at 16:49 +0200, daro wrote: Hi. I'm writing a TCP/IP server and client. On your website I found ready php script http://pl2.php.net/sockets but I have a question. For TCP/IP server the example script from your website has to be put on server as index.php file and the access to it could be f.e. http://192.168.1.11/index.php ? I don't know where should I put this script to be able to receive all datas and respond with proper strings. Your sincerely Dariusz Chorążewicz - Rozwiązania sms www.statsms.net, www.smscenter.pl GG: 346444 Tel: 696 061 543 You have to run your script from the command-line. Don't depend on apache to have it running. Also remember to set_time_limit(0) ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sockets
You should use/run it via PHP-CLI. It is a shell script. Ex: /usr/local/bin/php socket.php (on linux) or C:\PHP\php.exe socket.php (on windooz/M$-dos) Good luck. Hidayet Dogan On Tue, 12 Jul 2005, daro wrote: Hi. I'm writing a TCP/IP server and client. On your website I found ready php script http://pl2.php.net/sockets but I have a question. For TCP/IP server the example script from your website has to be put on server as index.php file and the access to it could be f.e. http://192.168.1.11/index.php ? I don't know where should I put this script to be able to receive all datas and respond with proper strings. Your sincerely Dariusz Chor??ewicz - Rozwi?zania sms www.statsms.net, www.smscenter.pl GG: 346444 Tel: 696 061 543 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sockets
On Tue, 2005-07-12 at 09:58 -0500, Greg Donald wrote: On 7/12/05, daro [EMAIL PROTECTED] wrote: I don't know where should I put this script to be able to receive all datas and respond with proper strings. You would run the script as a shell script from the command line. On windows you can just save the code as a regular php script then start it up from a DOS prompt like: c:\PHP\php.exe -f yoursocketfile.php or if you are using a *nix setup run it just as it is, making sure the first line points to your php binary, for example mine is /usr/bin/php. Chmod it so it's executable. -- Greg Donald Zend Certified Engineer MySQL Core Certification http://destiney.com/ More specificlly, --8- #!/usr/bin/php ?php // your script here ? --8- And then $ chmod +x socket.php $ ./socket.php OR $ /usr/bin/php -q socket.php If your on *NIX, remember the last to put the process on the background. Not sure how one would go on windows tho :( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sockets
Please, PLEASE Reply to All! Yes, you have to add something like --8- while(true) { // code here if( $someConditionThatWillMakeMeExit ) { break; } sleep(1); // to prevent excessive processor usage } --8- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sockets
hi all, On Tue, 2005-07-12 at 16:49 +0200, daro wrote: Also remember to set_time_limit(0) ;) PHP ENTER CONFUSION The *CLI* version of php has no max execution time by default (0) - Where's the php CLI version in php4? [PHP_HOME]/cli/php.exe and it reads a php.ini if it was in the SAME directory or as specified using -c [DIRECTORY] (but apparently ignoring the max_execution_time value even it was specified in php.ini) - Oh and what's the $PHP_HOME/php.exe in a typical php4 distribution? it's the CGI executable (according to the accompanying READM) - And what's the CLI one in php5? [PHP_HOME]/php.exe and it reads php-cli.ini!! (note that this was the CGI one in php4) - Oh la la and where's CGI one in php5? [PHP_HOME]/php-cgi.exe Can i ini_set() the value of max_execution_time during runtime when using the cli versions? YES!! I've done some personal experimentation to confirm all the above. Tested with PHP/4.3.9 and PHP/5.0.2 -ahmed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sockets
Since there was no reference to that on the PHP manual, I thought about mentioning it just to be safe. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sockets
Hi André, On 7/12/05, André Medeiros [EMAIL PROTECTED] wrote: Since there was no reference to that on the PHP manual, I thought about mentioning it just to be safe. yeah the manual is completely drak when it comes to php CLI binary -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sockets
On 7/12/05, Ahmed Saad [EMAIL PROTECTED] wrote: yeah the manual is completely drak when it comes to php CLI binary `php -h` tells you all the command line options.. and all the basic fuctionality is covered in the manual online. Seems complete to me. -- Greg Donald Zend Certified Engineer MySQL Core Certification http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sockets
On 7/13/05, Greg Donald [EMAIL PROTECTED] wrote: `php -h` tells you all the command line options.. and all the basic fuctionality is covered in the manual online. Seems complete to me. ehmm you weren't refering to the CLI version but anyways, I'd be grateful to anyone who points me to more information about other differences between the CGI and CLI versions (besides max_exection_times and configuration files). thanks -ahmed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sockets
Hello, Is there a special newsgroup for socket programming? regards Harry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Sockets
This may sound a bit cheeky, but I've spent most of today looking for some examples of sockets. I've managed to create a socket and it's connecting ok, but next I need to find a way of sending an ASCII string to the remote computer and echo-ing the results back to my screen. (Using a text box to submit the ascii string) This is for simulating comms between a UNIX server and a piece of electrical equipment (for which I'm using my laptop). Does anyone know of similar examples. Thanks in advance, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sockets - fine tunning
Hi, I think curt is right about transfer encoding being a problem, however i feel it may not be 'the' problem. This timing issue looks like you are running into a 'blocking' kind of situation. Cosmin, Have you tried the 'Connection: close' header? Getting back to transfer encoding you might want to look at the RFC - http://www.w3.org/Protocols/rfc2616/rfc2616.html where they explain how it's to be handled. all the best Curt Zirzow wrote: * Thus wrote Cosmin ([EMAIL PROTECTED]): On Sun, 2003-10-26 at 15:30, Raditha Dissanayake wrote: are you getting any 1xx status codes from the web server? here are the full headers: Transfer-Encoding: chunked This is probably the problem. If you inspect your data, you'll notice that it has extra characters in it right now. You can change your protocol version to HTTP/1.0 or send a header to tell the server you don't want chuncked (don't know that off hand). Curt -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha/megaupload/ Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 150 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sockets - fine tunning
* Thus wrote Cosmin ([EMAIL PROTECTED]): On Sun, 2003-10-26 at 15:30, Raditha Dissanayake wrote: are you getting any 1xx status codes from the web server? here are the full headers: Transfer-Encoding: chunked This is probably the problem. If you inspect your data, you'll notice that it has extra characters in it right now. You can change your protocol version to HTTP/1.0 or send a header to tell the server you don't want chuncked (don't know that off hand). Curt -- My PHP key is worn out PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sockets - fine tunning
are you getting any 1xx status codes from the web server? Cosmin wrote: I'm trying to make an application using XML-RPC, and I have the following problem: I use fsockopen() to simulate a POST to my local web-server. All goes very well except it's very very slow. Here is my code maybe someone could tell me what I'm doing wrong: = $url= parse_url($this-serverURL); $requestString= POST .$url['path']. HTTP/1.1\r\nHost: .$url['host'].\r\nContent-type: application/x-www.form-urlencoded\r\nContent-length: .strlen($this-requestData).\r\n\r\n.$this-requestData;; $fp = fsockopen($url['host'], 80, $err_num, $err_msg, 5); if ($fp) { //make the request to the xml-rpc server fputs($fp, $requestString); //gets the result while (!feof($fp)) { $response .= fgets($fp, 1024); } fclose($fp); $this-rawResponse=$response; $this-error=false; } else { $this-error=true; $this-errorMessage=$err_msg; } This is the slowest part of my script(about 16 seconds). The server's execution time is only 0.00064206123352051 seconds. I don't know why it takes so much to write a string to the socket and then to read the response. Here are the execution times: Server StartServer Stop 1067090777.5339 1067090777.5346 Client StartClient Stop 1067090777.5303 1067090794.5286 If someone knows a way on how to speed this up please tell me how to do it. Thank you for your time -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha/megaupload/ Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 150 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sockets - fine tunning
On Sun, 2003-10-26 at 15:30, Raditha Dissanayake wrote: are you getting any 1xx status codes from the web server? here are the full headers: HTTP/1.1 200 OK Date: Mon, 27 Oct 2003 06:15:30 GMT Server: Apache/1.3.27 (Unix) PHP/4.3.3 X-Powered-By: PHP/4.3.3 Transfer-Encoding: chunked Content-Type: text/xml Cosmin wrote: I'm trying to make an application using XML-RPC, and I have the following problem: I use fsockopen() to simulate a POST to my local web-server. All goes very well except it's very very slow. Here is my code maybe someone could tell me what I'm doing wrong: = $url= parse_url($this-serverURL); $requestString= POST .$url['path']. HTTP/1.1\r\nHost: .$url['host'].\r\nContent-type: application/x-www.form-urlencoded\r\nContent-length: .strlen($this-requestData).\r\n\r\n.$this-requestData;; $fp = fsockopen($url['host'], 80, $err_num, $err_msg, 5); if ($fp) { //make the request to the xml-rpc server fputs($fp, $requestString); //gets the result while (!feof($fp)) { $response .= fgets($fp, 1024); } fclose($fp); $this-rawResponse=$response; $this-error=false; } else { $this-error=true; $this-errorMessage=$err_msg; } This is the slowest part of my script(about 16 seconds). The server's execution time is only 0.00064206123352051 seconds. I don't know why it takes so much to write a string to the socket and then to read the response. Here are the execution times: Server StartServer Stop 1067090777.5339 1067090777.5346 Client StartClient Stop 1067090777.5303 1067090794.5286 If someone knows a way on how to speed this up please tell me how to do it. Thank you for your time -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha/megaupload/ Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 150 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] sockets - fine tunning
I'm trying to make an application using XML-RPC, and I have the following problem: I use fsockopen() to simulate a POST to my local web-server. All goes very well except it's very very slow. Here is my code maybe someone could tell me what I'm doing wrong: = $url= parse_url($this-serverURL); $requestString= POST .$url['path']. HTTP/1.1\r\nHost: .$url['host'].\r\nContent-type: application/x-www.form-urlencoded\r\nContent-length: .strlen($this-requestData).\r\n\r\n.$this-requestData;; $fp = fsockopen($url['host'], 80, $err_num, $err_msg, 5); if ($fp) { //make the request to the xml-rpc server fputs($fp, $requestString); //gets the result while (!feof($fp)) { $response .= fgets($fp, 1024); } fclose($fp); $this-rawResponse=$response; $this-error=false; } else { $this-error=true; $this-errorMessage=$err_msg; } This is the slowest part of my script(about 16 seconds). The server's execution time is only 0.00064206123352051 seconds. I don't know why it takes so much to write a string to the socket and then to read the response. Here are the execution times: Server StartServer Stop 1067090777.5339 1067090777.5346 Client StartClient Stop 1067090777.5303 1067090794.5286 If someone knows a way on how to speed this up please tell me how to do it. Thank you for your time -- Cosmin [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sockets - fine tunning
* Thus wrote Cosmin ([EMAIL PROTECTED]): I'm trying to make an application using XML-RPC, and I have the following problem: I use fsockopen() to simulate a POST to my local web-server. All goes very well except it's very very slow. Here is my code maybe someone could tell me what I'm doing wrong: = $url= parse_url($this-serverURL); $requestString= POST .$url['path']. HTTP/1.1\r\nHost: .$url['host'].\r\nContent-type: application/x-www.form-urlencoded\r\nContent-length: .strlen($this-requestData).\r\n\r\n.$this-requestData;; Have you tried to simulate this on a web browser? My guess is there might be some dns issue somewhere causing the webserver to take a while before even processing the request. Try and find out where the bottleneck is by echo'ing between steps to see where the problem is, for example: echo time(), \n; $fp = fsockopen($url['host'], 80, $err_num, $err_msg, 5); echo time(), \n; Curt -- My PHP key is worn out PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sockets - fine tunning
On Sat, 2003-10-25 at 17:42, Curt Zirzow wrote: * Thus wrote Cosmin ([EMAIL PROTECTED]): I'm trying to make an application using XML-RPC, and I have the following problem: I use fsockopen() to simulate a POST to my local web-server. All goes very well except it's very very slow. Here is my code maybe someone could tell me what I'm doing wrong: = $url= parse_url($this-serverURL); $requestString= POST .$url['path']. HTTP/1.1\r\nHost: .$url['host'].\r\nContent-type: application/x-www.form-urlencoded\r\nContent-length: .strlen($this-requestData).\r\n\r\n.$this-requestData;; Have you tried to simulate this on a web browser? My guess is there might be some dns issue somewhere causing the webserver to take a while before even processing the request. Try and find out where the bottleneck is by echo'ing between steps to see where the problem is, for example: echo time(), \n; $fp = fsockopen($url['host'], 80, $err_num, $err_msg, 5); echo time(), \n; Curt -- My PHP key is worn out PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ Here are the times: 1:1067092779.6042 2:1067092795.7176 And here is the code: echo '1:'.getmicrotime(),\n\n; while($data=fread($fp, 32768)) { $response.=$data; } echo '2:'.getmicrotime(),\n\n; I don't know what else to do ... I've changed the buffer length but it's still the same :(( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php sockets was Re: [PHP] socket_write eats data - solved
Probably your problems about i can send about seven messages per second may be relationed to OS's tcp connection stream buffering... try to flush every fd after write to it. I wrote a multi-threaded (pcntl_fork()) application in phpcli using many sockets and they worked well... array iterations are fast and easy too, as they have only one level... so I believe that this is really relationed to socket flushing stuffs...you can also use select() to determine when a fd is ready for write and implement a write spool... only a ideia, but probably will spent more time with the same results... well.. flush then may resolve it. Daniel Souza Raditha Dissanayake [EMAIL PROTECTED] escreveu na mensagem news:[EMAIL PROTECTED] Hi thomas, Thomas Weber wrote: IMAP? We were talking about IRC, Used imap as an example. the Internet Relay Chat. In detail, my problems doesn't even refer to IRC directly, as i am developing a server for a html-based webchat, but the server-structure and the messages are nearly the same. Yes my questions was how are you going to maintain the connection between two different connectsion. As far as i know sockets cannot be serialized in php4. Once you realize the basics of socket-multicasting, it is no problem to maintain hundreds of simultanous TCP-connects via arrays of sockets, also called descriptor-sets. PHP seems to directly use the underlying C- libraries, so everything you can imagine is possible. Thanx i am aware of it -- http://www.radinks.com/upload Drag and Drop File Uploader. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php sockets was Re: [PHP] socket_write eats data - solved
Hi thomas, Thomas Weber wrote: IMAP? We were talking about IRC, Used imap as an example. the Internet Relay Chat. In detail, my problems doesn't even refer to IRC directly, as i am developing a server for a html-based webchat, but the server-structure and the messages are nearly the same. Yes my questions was how are you going to maintain the connection between two different connectsion. As far as i know sockets cannot be serialized in php4. Once you realize the basics of socket-multicasting, it is no problem to maintain hundreds of simultanous TCP-connects via arrays of sockets, also called descriptor-sets. PHP seems to directly use the underlying C- libraries, so everything you can imagine is possible. Thanx i am aware of it -- http://www.radinks.com/upload Drag and Drop File Uploader. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sockets tutorial problem in Mac OSX
Hello, I'm just getting my feet wet with a Dev Shed sockets tutorial (http://www.devshed.com/Server_Side/PHP/SocketProgramming/page5.html). I am having a little problem with one of the tutorial code samples, which should socket_write some text back to the client--except it's not doing that. Here's the snippet: // write a welcome message to the client $welcome = Roll up, roll up, to the greatest show on earth!\n? ; socket_write($spawn, $welcome, strlen ($welcome)) or die(Could not send connect string\n); // keep looping and looking for client input do { // read client input $input = socket_read($spawn, 1024, 1) or die(Could not read input\n); if (trim($input) != ) { echo Received input: $input\n; // if client requests session end if (trim($input) == END) { // close the child socket // break out of loop socket_close($spawn); break; } // otherwise... else { // reverse client input and send back $output = strrev($input) . \n; socket_write($spawn, $output . ? , strlen (($output)+2)) or die(Could not write output\n); echo Sent output: . trim($output) . \n; } } } while (true); And the output to the Telnet client: [Valhalla:~] rene% telnet 192.168.0.77 1234 Trying 192.168.0.77... Connected to 192.168.0.77. Escape character is '^]'. Roll up, roll up, to the greatest show on earth! ? Hello, this is a test. END Connection closed by foreign host. [Valhalla:~] rene% Server output: % /usr/local/php/bin/php -q socket3.php4 Waiting for connections... Received connection request Received input: Hello, this is a test. Sent output: .tset a si siht ,olleH Received input: END Socket terminated This is almost exactly the same code as that used in the very first example, with the obvious addition of debug messages and a do-while loop [Valhalla:~] rene% According to the tutorial, the client should see the string reversed, but that's not happening... In the previous tutorial example it did reverse and output to the client, and the code looks identical, save for the do...while loop. Here's what the tutorial says should happen: Here's the output of a sample session: $ telnet 192.168.1.99 1234 Trying 192.168.1.99... Connected to medusa. Escape character is '^]'. Roll up, roll up, to the greatest show on earth! ? Look Ma...all backwards sdrawkcab lla...aM kooL ? jack frost tsorf kcaj ? END Connection closed by foreign host. And here are the corresponding debug messages generated on the server: $ /usr/local/bin/php -q server.php Waiting for connections... Received connection request Received input: Look Ma...all backwards Sent output: sdrawkcab lla...aM kooL Received input: jack frost Sent output: tsorf kcaj Received input: END Socket terminated Any ideas? ...Rene -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Resume PHP Sockets?
Is it possible to resume persistent sockets opened with pfsockopen? I really need to know if it's possible to resume a socket from another script, like if I've saved the socket into a session variable. Thank You -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sockets and Header data
Ever since PHP 3, I have been using Sockets to pass GET and POST information. Yes, now that there is the caching ability, I no longer need to do it that way, however it has never failed me and since I deal with some high visibility applications, I am reluctant to change. With my experience limited to GET and POST, I do not know the format of data that is sent via the PHP header() function. For instance, if I send header("Content-type: text/html"); header("Content-Disposition: filename=myfile"); what is actually sent? If I send POST data, the data string looks like POST http://209.204.172.137:80/mysql/php/menu.php HTTP/1.0 Accept-Language: en-us Host: 209.204.172.137:80 Connection: close Content-type: application/x-www-form-urlencoded Content-length: 21 session_id=1047421540 How would the two header examples above look? Is there a PHP application that can intercept the Socket stream? Todd --
[PHP] sockets: resource(20) of type (Unknown)
Hi - I have an problem and I'm not sure how to proceed troubleshooting. I have a socket connection that I'm making to a local stunnel daemon. The connection works and is valid until it seemingly dies and the resource type becomes unknown. at timestamp: 1044900028.6608 my object has this resource: resource(20) of type (stream) at timestamp: 1044900028.6808 it becomes: resource(20) of type (Unknown) I don't think this is a timeout issue, and I can perform all of my functionality via a telnet session without any problems as well. This code used to work great, I have made recent upgrades and changed environments. However the code consistently dies in the exact place, a place where other fsocket reads and writes are successfully been made. Any suggestions would be appreciated. Regards, Jason k Larson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] sockets (again)
Hi, I really need some help here because I am going to lose my mind otherwise!! A script that was running fine Friday has decided not to work for no apparent reason today. The problem seems to be with a socket_create that just stops the script, so I created a simple test script as shown below to see what happens. When I run this is simply drops out at the socket_create, no error message, nothing. Again this worked fine Friday and nothing has changed on my machine. I am running 4.2.3 on Win2K... any ideas? Help!! G. $zone = 192.168.0.60; $port = 1; $command = play; echo('here'); $slip_socket = socket_create (AF_INET, SOCK_STREAM, 0); echo('here 2'); if ($slip_socket 0) { echo socket_create() failed: reason: . socket_strerror ($slip_socket) . \n; } else { $result = socket_connect ($slip_socket, $zone, $port); if ($result 0) { echo socket_connect() failed.\nReason: ($result) . socket_strerror($result) . \n; } } $command=$command.\n; echo('Sending command: '.$command.' for '.$zone.'\n'); socket_write ($slip_socket, $command, strlen ($command)); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] sockets
Hi, I realise that sockets is still 'experimental' but any help will be much appreciated. I am developing a queue system to send commands across from a server to a client using sockets. Problem is that the I keep getting a 'connection reset by peer' error after the first command is sent. The server script itself is in a loop which I believe should maintain the socket connection. I am using socket_write() to send the data across the socket, and I am wondering if I should be using socket_send()? Does anyone have any ideas or experience of doing this? My PHP version is 4.2.3. My server software is running on Windows and client software on Linux although eventually both will be on Linux. Thanks. Gareth -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sockets
I'm not sure if it would be helpful, but I wrote a quick PHP socket application that implements a specialized HTTP proxy. It's a quick hack of sorts, but I have found it to be very stable, and it uses the latest sockets API. It consists of only one small PHP script, and it's fairly well commented. You're welcome to check it out, and maybe it can answer some of your questions by example. http://protoscope.org/ Chris --- Gareth Thomas [EMAIL PROTECTED] wrote: I realise that sockets is still 'experimental' but any help will be much appreciated. I am developing a queue system to send commands across from a server to a client using sockets. Problem is that the I keep getting a 'connection reset by peer' error after the first command is sent. The server script itself is in a loop which I believe should maintain the socket connection. I am using socket_write() to send the data across the socket, and I am wondering if I should be using socket_send()? Does anyone have any ideas or experience of doing this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] sockets
I am in the beginning stages of writing my first socket based php app from scratch. However I think I've quickly picked up a bad coding habbit when reading from sockets. I'm doing the following: //writing the socket socket_write ($socket,blah blah$CRLF, strlen ($in)); //sleeping for 1 second... sleep(1); //after sleeping, i'll check to see if there is input... $output = socket_read($socket,1024); Can anyone give me a better example of how I should be doing this? I could get events sent back at any time. I tried the example on the php.net's documentation (binding and accepting) but it failed to work for me on the latest php (4.3.0pre2). It just kept timing out for me. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sockets
This is how sockets work, if you close the process holding the socket, the conection is closed. There is no function reopen_the_old_conection. You are not clear about what you are trying to achive, but maybe you should rethink your design. Gareth Thomas wrote: Hi, I am running 4.3.0pre2 on RH 7.2 and on Windows2k I am trying to implement a socket based client/server communication program with the server being on the Linux side and the current test client on windows (although it will be on Linux eventually). A series of commands is sent by the client side which consists of 2 PHP pages, the first with some buttons and the second that sends the button commands to the server using sockets. The problem I am finding is that it appears PHP closes the socket connection once the second script has ended and it returns back to the first. Is there anyway of keeping the socket 'open' or can someone suggest a better way of doing this... Thanks in advance -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] sockets
Hi, I am running 4.3.0pre2 on RH 7.2 and on Windows2k I am trying to implement a socket based client/server communication program with the server being on the Linux side and the current test client on windows (although it will be on Linux eventually). A series of commands is sent by the client side which consists of 2 PHP pages, the first with some buttons and the second that sends the button commands to the server using sockets. The problem I am finding is that it appears PHP closes the socket connection once the second script has ended and it returns back to the first. Is there anyway of keeping the socket 'open' or can someone suggest a better way of doing this... Thanks in advance
[PHP] Sockets
Hey everyone, Does anybody know what the current support / functionality for PHP with sockets is? According to the documentation, all the socket_ functions should be included in PHP = 4.1.0. I'm currently running 4.2.1 and PHP doesn't seem to recognize these functions (socket_send, socket_write, etc). Anybody know if there's anything special I have to do to get it working? // Asmodean -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sockets
Yep, if you're using UNIX and compiling from source, you must add this switch to the command line when you're configuring and compiling PHP: --enable-sockets (e.g.: ./configure --enable-sockets). If you're using a prepackaged version (RPM or Windows) then you should look into the documentation for your version to see if this extension was included when the package was compiled from the source. Cheers, Marco On Mon, 2002-10-07 at 14:22, Asmodean wrote: Hey everyone, Does anybody know what the current support / functionality for PHP with sockets is? According to the documentation, all the socket_ functions should be included in PHP = 4.1.0. I'm currently running 4.2.1 and PHP doesn't seem to recognize these functions (socket_send, socket_write, etc). Anybody know if there's anything special I have to do to get it working? // Asmodean -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sockets
Is it possible to read and write to multiple sockets at once with php? Can anyone please answer that question? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] ADVANCED PHP (SOCKETS)
I would like to know, what I have to do to make my application handle multiple connections? My current application only handle one user per time. Sorry about my English, but i live in Brazil, if anybody could help me answer me [EMAIL PROTECTED] . Thanky you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: ADVANCED PHP (SOCKETS)
Take a look at the pcntl functions. In particular the pcntl_fork() function. On Wed, 14 Aug 2002, Gustavo Almeida wrote: I would like to know, what I have to do to make my application handle multiple connections? My current application only handle one user per time. Sorry about my English, but i live in Brazil, if anybody could help me answer me [EMAIL PROTECTED] . Thanky you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: ADVANCED PHP (SOCKETS)
Although pcntl and fork() were mentioned, you might want to look at socket_select() as an alternative. Using socket_select(), you can set up a multiplexer to handle multiple sockets at the same time. (Or roughly the same time...) J Gustavo Almeida wrote: I would like to know, what I have to do to make my application handle multiple connections? My current application only handle one user per time. Sorry about my English, but i live in Brazil, if anybody could help me answer me [EMAIL PROTECTED] . Thanky you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] ADVANCED PHP (SOCKETS)
I've got a fully functioning socket server that I use for monitoring written in PHP... email if you want the full script, too big to waste peoples time with here. --- /* Neunzig neun Möglichkeiten zu sterben // Ich bin nur ein anderer Zahn in der Maschine. */ On Wed, 14 Aug 2002 15:09:09 Gustavo Almeida wrote: I would like to know, what I have to do to make my application handle multiple connections? My current application only handle one user per time. Sorry about my English, but i live in Brazil, if anybody could help me answer me [EMAIL PROTECTED] . Thanky you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Outgrown your current e-mail service? Get a 25MB Inbox, POP3 Access, No Ads and No Taglines with LYCOS MAIL PLUS. http://login.mail.lycos.com/brandPage.shtml?pageId=plus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sockets 'requested address is not valid in its context'
On Sat, 6 Jul 2002, Zac Hillier wrote: I'm opening a port on a remote machine presently I'm using fsockopen() which is fine for opening the port and sending data however I'm having trouble reading data back from the port. So I've considered using socket functions but do not appear to be able to get a connection. When I run the code below pointing to 127.0.0.1 everything runs fine however when I point to 192.168.123.193 (Another machine on the local network without a server running) I get these errors. You can't bind to a socket on another machine. You have to bind the socket to a local address (i.e., on your machine) and then either listen for incoming connections or initiate an outbound connection from that socket. miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sockets 'requested address is not valid in its context'
Hi All, I'm opening a port on a remote machine presently I'm using fsockopen() which is fine for opening the port and sending data however I'm having trouble reading data back from the port. So I've considered using socket functions but do not appear to be able to get a connection. When I run the code below pointing to 127.0.0.1 everything runs fine however when I point to 192.168.123.193 (Another machine on the local network without a server running) I get these errors. Warning: socket_bind() unable to bind address [10049]: The requested address is not valid in its context. in D:\php-dev\new.php on line 20 socket_bind() failed: reason: The requested address is not valid in its context. Warning: socket_listen() unable to listen on socket [10022]: An invalid argument was supplied. in D:\php-dev\new.php on line 26 socket_listen() failed: reason: An invalid argument was supplied. What does 'requested address is not valid in its context' mean? Thanks Zac Code: ?php error_reporting (E_ALL); /* Allow the script to hang around waiting for connections. */ set_time_limit (0); /* Turn on implicit output flushing so we see what we're getting * as it comes in. */ ob_implicit_flush (); $address = 192.168.123.193; $port = 5331; if (($sock = socket_create(AF_INET, SOCK_STREAM, getprotobyname(TCP))) 0) { echo socket_create() failed: reason: . socket_strerror ($sock) . br; } else { echo 'socketbr'; } if (($ret = socket_bind($sock, $address, $port)) == false) { echo socket_bind() failed: reason: . socket_strerror(socket_last_error($sock)) . br; } else { echo 'bindbr'; } if (($ret = socket_listen ($sock, 5)) == false) { echo socket_listen() failed: reason: . socket_strerror(socket_last_error($sock)) . br; } else { echo 'listenbr'; } socket_close ($sock); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP sockets/daemon problem
I'm trying to write a simple PHP script that communicates with a daemon running on the same server. Basically, the daemon just accepts an integer and returns an integer: [josh@jlevine-research josh]$ telnet 127.0.0.1 60324 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 9 25Connection closed by foreign host. When I try doing this with PHP, however, the output is 2[]5 (where [] == a small square symbol). Here is the script: ?php $fp = fsockopen(127.0.0.1, 60324, $errno, $errstr); if (!$fp) { echo ERROR: $errno - $errstrbr\n; } else { socket_set_blocking ($fp, 1); socket_set_timeout($fp, 200); fwrite($fp,9\n); $return = fread($fp,4); echo $return; fclose($fp); } ? I've tried various string format and type-casting functions with no results (usually just returns nothing after formatted). Any ideas? Thanks in advance, Josh Levine -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP sockets/daemon problem
Some great articles for sockets...might help out... http://www.phpbeginner.com/columns/demitrious/sockets http://www.phpbeginner.com/columns/demitrious/sockets-connection B i g D o g - Original Message - From: Josh Levine [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, June 26, 2002 11:32 AM Subject: [PHP] PHP sockets/daemon problem I'm trying to write a simple PHP script that communicates with a daemon running on the same server. Basically, the daemon just accepts an integer and returns an integer: [josh@jlevine-research josh]$ telnet 127.0.0.1 60324 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 9 25Connection closed by foreign host. When I try doing this with PHP, however, the output is 2[]5 (where [] == a small square symbol). Here is the script: ?php $fp = fsockopen(127.0.0.1, 60324, $errno, $errstr); if (!$fp) { echo ERROR: $errno - $errstrbr\n; } else { socket_set_blocking ($fp, 1); socket_set_timeout($fp, 200); fwrite($fp,9\n); $return = fread($fp,4); echo $return; fclose($fp); } ? I've tried various string format and type-casting functions with no results (usually just returns nothing after formatted). Any ideas? Thanks in advance, Josh Levine -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP sockets/daemon problem
Thanks! Those were a huge help...turns out the problem was with the daemon and not my code. --Josh Levine B I G D O G wrote: Some great articles for sockets...might help out... http://www.phpbeginner.com/columns/demitrious/sockets http://www.phpbeginner.com/columns/demitrious/sockets-connection B i g D o g - Original Message - From: Josh Levine [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, June 26, 2002 11:32 AM Subject: [PHP] PHP sockets/daemon problem I'm trying to write a simple PHP script that communicates with a daemon running on the same server. Basically, the daemon just accepts an integer and returns an integer: [josh@jlevine-research josh]$ telnet 127.0.0.1 60324 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 9 25Connection closed by foreign host. When I try doing this with PHP, however, the output is 2[]5 (where [] == a small square symbol). Here is the script: ?php $fp = fsockopen(127.0.0.1, 60324, $errno, $errstr); if (!$fp) { echo ERROR: $errno - $errstrbr\n; } else { socket_set_blocking ($fp, 1); socket_set_timeout($fp, 200); fwrite($fp,9\n); $return = fread($fp,4); echo $return; fclose($fp); } ? I've tried various string format and type-casting functions with no results (usually just returns nothing after formatted). Any ideas? Thanks in advance, Josh Levine -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] --enabel-pnctl / php sockets
I have recently discovered php's binary capabilities, and am using it to write a virtual isp management system, so that a php binary will listen to a port, and spit out an interface, such as webmin, etc...(http://vispman.org) This interface will be able to add virtual domains, restart dns, qmail, etc... I have seen a couple of other php binary projects(using php sockets), such as phserv, where an entire web server (like apache) has been written in nothing but php. I tried to install these, and they wouldn't run without php compiled with --enable-pcntl Now, it is my understanding that --enable-pcntl is for process control, and it only works if you are compiling php as a cgi module, and not as an apache add-on. (at least that is the error I got , when taking a redhat php rpm, and editing the spec file to include the --enable-pcntl) Is there any way to get that to compile, while maintaining all original functionality in the redhat php rpm? What I am really looking for here, is a php binary, that will spit out a web control interface(standard web page, with forms on the client side) That will listen on a non-apache port, and if a connections is detected, lock it in securely... But...still allow other connections, (like apache listens to minservers/maxserversmultiple sessions on one port) The idea being that one isp might have multiple admins/staff entering in domain information. Any help on this is much appreciated. Barry Smoke Project Leader Vispman.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] --enabel-pnctl / php sockets
Check out phpserv. -Original Message- From: Barry Smoke [mailto:[EMAIL PROTECTED]] Sent: 06 May 2002 19:07 To: [EMAIL PROTECTED] Subject: [PHP] --enabel-pnctl / php sockets I have recently discovered php's binary capabilities, and am using it to write a virtual isp management system, so that a php binary will listen to a port, and spit out an interface, such as webmin, etc...(http://vispman.org) This interface will be able to add virtual domains, restart dns, qmail, etc... I have seen a couple of other php binary projects(using php sockets), such as phserv, where an entire web server (like apache) has been written in nothing but php. I tried to install these, and they wouldn't run without php compiled with --enable-pcntl Now, it is my understanding that --enable-pcntl is for process control, and it only works if you are compiling php as a cgi module, and not as an apache add-on. (at least that is the error I got , when taking a redhat php rpm, and editing the spec file to include the --enable-pcntl) Is there any way to get that to compile, while maintaining all original functionality in the redhat php rpm? What I am really looking for here, is a php binary, that will spit out a web control interface(standard web page, with forms on the client side) That will listen on a non-apache port, and if a connections is detected, lock it in securely... But...still allow other connections, (like apache listens to minservers/maxserversmultiple sessions on one port) The idea being that one isp might have multiple admins/staff entering in domain information. Any help on this is much appreciated. Barry Smoke Project Leader Vispman.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] --enabel-pnctl / php sockets
After further research, (reading the redhat php spec file completely) I discovered how they were making it, so that php binaries, and apache php module was working at the same time... The rpm builds the cgi root, and installs it, and the builds the apache root, and installs that over the cgi installation, which overwrites some things, but fortunately(as the spec file documents) they are compatible... So, I simply went to the spec file, where it built the cgi tree, and --enable-pcntl \ and rpm -ba phpx.spec, and viola, pcntl support in the php binary! Hope this helps others Barry Smoke Project Leader Vispman.org -Original Message- From: Barry Smoke [mailto:[EMAIL PROTECTED]] Sent: Monday, May 06, 2002 1:07 PM To: [EMAIL PROTECTED] Subject: [PHP] --enabel-pnctl / php sockets I have recently discovered php's binary capabilities, and am using it to write a virtual isp management system, so that a php binary will listen to a port, and spit out an interface, such as webmin, etc...(http://vispman.org) This interface will be able to add virtual domains, restart dns, qmail, etc... I have seen a couple of other php binary projects(using php sockets), such as phserv, where an entire web server (like apache) has been written in nothing but php. I tried to install these, and they wouldn't run without php compiled with --enable-pcntl Now, it is my understanding that --enable-pcntl is for process control, and it only works if you are compiling php as a cgi module, and not as an apache add-on. (at least that is the error I got , when taking a redhat php rpm, and editing the spec file to include the --enable-pcntl) Is there any way to get that to compile, while maintaining all original functionality in the redhat php rpm? What I am really looking for here, is a php binary, that will spit out a web control interface(standard web page, with forms on the client side) That will listen on a non-apache port, and if a connections is detected, lock it in securely... But...still allow other connections, (like apache listens to minservers/maxserversmultiple sessions on one port) The idea being that one isp might have multiple admins/staff entering in domain information. Any help on this is much appreciated. Barry Smoke Project Leader Vispman.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] sockets and flush()
i have a script that makes a socket connection about halfway through the page. nothing on the page prints until the socket operation is finished, even if i call flush() prior to the socket operation. does anyone now of a way to force PHP to output the buffer prior to executing the socket code? thanks! dietrich [EMAIL PROTECTED] dietrich.ganx4.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sockets and flush()
dietrich wrote: i have a script that makes a socket connection about halfway through the page. nothing on the page prints until the socket operation is finished, even if i call flush() prior to the socket operation. does anyone now of a way to force PHP to output the buffer prior to executing the socket code? thanks! dietrich [EMAIL PROTECTED] dietrich.ganx4.com Are you using Netscape 4.x and possibly making the socket connection while inside a main table tag? Nescape 4.x series doesn't usually draw a table until the close tag is found or the page ends. Cheers, Rob. -- .-. | Robert Cummings | :-`. | Webdeployer - Chief PHP and Java Programmer | :--: | Mail : mailto:[EMAIL PROTECTED] | | Phone : (613) 731-4046 x.109 | :--: | Website : http://www.webmotion.com | | Fax : (613) 260-9545 | `--' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] sockets and flush()
no tables. my test script prints a single string prior to the sockets code. thx, dietrich -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 09, 2002 11:12 AM To: dietrich Cc: [EMAIL PROTECTED] Subject: Re: [PHP] sockets and flush() dietrich wrote: i have a script that makes a socket connection about halfway through the page. nothing on the page prints until the socket operation is finished, even if i call flush() prior to the socket operation. does anyone now of a way to force PHP to output the buffer prior to executing the socket code? thanks! dietrich [EMAIL PROTECTED] dietrich.ganx4.com Are you using Netscape 4.x and possibly making the socket connection while inside a main table tag? Nescape 4.x series doesn't usually draw a table until the close tag is found or the page ends. Cheers, Rob. -- .-. | Robert Cummings | :-`. | Webdeployer - Chief PHP and Java Programmer | :--: | Mail : mailto:[EMAIL PROTECTED] | | Phone : (613) 731-4046 x.109 | :--: | Website : http://www.webmotion.com | | Fax : (613) 260-9545 | `--' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] sockets and flush()
Are you using ob_start () and ob_end_flush() ? If not then declaring ob_start () as the very first ? ob_start (ob_gzhandler); function call and ob_end_flush() where you want the string to output should do the trick. Matthew Luchak Webmaster Kaydara Inc. [EMAIL PROTECTED] -Original Message- From: Dietrich Ayala [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 09, 2002 5:39 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: [PHP] sockets and flush() no tables. my test script prints a single string prior to the sockets code. thx, dietrich -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 09, 2002 11:12 AM To: dietrich Cc: [EMAIL PROTECTED] Subject: Re: [PHP] sockets and flush() dietrich wrote: i have a script that makes a socket connection about halfway through the page. nothing on the page prints until the socket operation is finished, even if i call flush() prior to the socket operation. does anyone now of a way to force PHP to output the buffer prior to executing the socket code? thanks! dietrich [EMAIL PROTECTED] dietrich.ganx4.com Are you using Netscape 4.x and possibly making the socket connection while inside a main table tag? Nescape 4.x series doesn't usually draw a table until the close tag is found or the page ends. Cheers, Rob. -- .-. | Robert Cummings | :-`. | Webdeployer - Chief PHP and Java Programmer | :--: | Mail : mailto:[EMAIL PROTECTED] | | Phone : (613) 731-4046 x.109 | :--: | Website : http://www.webmotion.com | | Fax : (613) 260-9545 | `--' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] sockets and flush()
Hmmm I'm no expert on web IO between Apache and PHP, but my guess is that Apache is holding the data and waiting for more. To verify this I recommend that you try running from a shell cgi and see if your string is flushed to stdio as it should. I remember running into a similar problem one time while performing a remote file(). Cheers, Rob. Dietrich Ayala wrote: no tables. my test script prints a single string prior to the sockets code. thx, dietrich -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 09, 2002 11:12 AM To: dietrich Cc: [EMAIL PROTECTED] Subject: Re: [PHP] sockets and flush() dietrich wrote: i have a script that makes a socket connection about halfway through the page. nothing on the page prints until the socket operation is finished, even if i call flush() prior to the socket operation. does anyone now of a way to force PHP to output the buffer prior to executing the socket code? thanks! dietrich [EMAIL PROTECTED] dietrich.ganx4.com Are you using Netscape 4.x and possibly making the socket connection while inside a main table tag? Nescape 4.x series doesn't usually draw a table until the close tag is found or the page ends. -- .-. | Robert Cummings | :-`. | Webdeployer - Chief PHP and Java Programmer | :--: | Mail : mailto:[EMAIL PROTECTED] | | Phone : (613) 731-4046 x.109 | :--: | Website : http://www.webmotion.com | | Fax : (613) 260-9545 | `--' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sockets with windows / win32 - 'call to undefined function: ...'
Hi.. The error I get is this one: Fatal error: Call to undefined function: socket() i'm 100% positive that all my code is correct.. anyone else have this problem, or anyone else NOT having this problem? I have a win2000 with iis 5.0 and it's latest updates. the latest version of php too.. Best regards, -Oddis-
RE: [PHP] Sockets with windows / win32 - 'call to undefined function: ...'
Socket() function does not exist in PHP at all. Use fsockopen() instead. http://www.php.net/fsockopen Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com -Original Message- From: Odd Arne Beck [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 1:23 AM To: [EMAIL PROTECTED] Subject: [PHP] Sockets with windows / win32 - 'call to undefined function: ...' Hi.. The error I get is this one: Fatal error: Call to undefined function: socket() i'm 100% positive that all my code is correct.. anyone else have this problem, or anyone else NOT having this problem? I have a win2000 with iis 5.0 and it's latest updates. the latest version of php too.. Best regards, -Oddis- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sockets and Telnet
Has anyone created a telnet session in php with sockets and can give me some help on setting one up? Thank you, Ray Hunter Firmware Engineer I ENTERASYS NETWORKS Phone: 801.887.9888 Fax:801.972.5789 Email: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] www:www.enterasys.com http://www.enterasys.com
Re: [PHP] Sockets and Telnet
On Tue, 19 Mar 2002, Hunter, Ray wrote: Has anyone created a telnet session in php with sockets and can give me some help on setting one up? Take a look at PHP Shell to see how it's done. http://www.gimpster.com/php/phpshell/index.php Cheers, Nick Winfield. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php