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 'socket<br>'; } if (($ret = socket_bind($sock, $address, $port)) == false) { echo "socket_bind() failed: reason: " . socket_strerror(socket_last_error($sock)) . "<br>"; } else { echo 'bind<br>'; } if (($ret = socket_listen ($sock, 5)) == false) { echo "socket_listen() failed: reason: " . socket_strerror(socket_last_error($sock)) . "<br>"; } else { echo 'listen<br>'; } socket_close ($sock); ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php