Re: Use sockets under windows
| From: | Delbono Nicola | Date: | Sun, 18 Nov 2001 15:25:50 +0000 |
| Subject: | Re: Use sockets under windows | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-10473@lists.php.net to get a copy of this message | ||
Hello.
I thought Sockets Under win didn't work..
maybe you can try with this other script:
http://marc.theaimsgroup.com/?l=php-general&m=98225134721753&w=2
----- Original Message -----
From: "Walter Gyr" <walter.gyr@gywu-tex.ch>
To: <php-windows@lists.php.net>
Sent: Sunday, November 18, 2001 8:59 AM
Subject: [PHP-WIN] Use sockets under windows
> Hi
>
> I'm looking for a sample about sockets for windows NT.
> I want test the sample from manual bad doesnt work with Windows.
> I know that the window version has diffrent function names.
>
> ?php
> error_reporting (E_ALL);
> set_time_limit (0);
> $address = '192.168.1.2';
> $port = 4711;
> if (($sock = socket_create (AF_INET, SOCK_STREAM, 0)) < 0) {
> echo "socket() failed: reason: " . strerror ($sock) . "\n";
> }
> if (($ret = socket_bind ($sock, $address, $port)) < 0) {
> echo "bind() failed: reason: " . strerror ($ret) . "\n";
> }
> if (($ret = socket_listen ($sock, 5)) < 0) {
> echo "listen() failed: reason: " . strerror ($ret) . "\n";
> }
> do {
> if (($msgsock = socket_accept($sock)) < 0) {
> echo "accept_connect() failed: reason: " . strerror ($msgsock) .
> "\n";
> break;
> }
> do {
> $buf = '';
> $ret = socket_read ($msgsock, $buf, 2048);
> if ($ret < 0) {
> echo "read() failed: reason: " . strerror ($ret) . "\n";
> break 2;
> }
> if ($ret == 0) {
> break 2;
> }
> $buf = trim ($buf);
> if ($buf == 'quit') {
> close ($msgsock);
> break 2;
> }
> $talkback = "PHP: You said '$buf'.\n";
> socket_write ($msgsock, $talkback, strlen ($talkback));
> echo "$buf\n";
> } while (true);
> socket_close ($msgsock);
> } while (true);
> socket_close ($sock);
> ?>
>
> The error message is always "Cannot bind the address" ??
>
> Thanks very much
>
> Walter
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
> For additional commands, e-mail: php-windows-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>