sockets ??

From: Date: Wed, 19 Dec 2001 22:29:08 +0000
Subject: sockets ??
Groups: php.general 
Request: Send a blank email to php-general+get-78258@lists.php.net to get a copy of this message
have the below code.. and am having two issues.. the first is that str_read comes up with an error 'read() expects parameter 2 to be long, string given' - is this because i am recieving binary from host? the value returned is totally empty .. i know i need to hanshake and all but how do I work out what the server is asking so i can respond in kind? (yes i have read the rfc ..) ?? cheers brendan <?php error_reporting (E_ALL); $port = '23'; $address = '202.14.186.30'; /* Create a TCP/IP socket. */ $socket = socket_create (AF_INET, SOCK_STREAM, 0); if ($socket < 0) {
    echo "socket_create() failed: reason: " . socket_strerror ($socket) . "\n";
} else {
    "socket_create() successful:\n";
} echo "Attempting to connect to '$address' on port '$port'..."; $result = socket_connect ($socket, $address, $port); if ($result < 0) {
    echo "socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "\n";
} else {
    echo "<BR>OK.\n";
} $in = ''; $out = ''; while (socket_read ($socket, $out, 1024)) {
    echo ord($out);
} echo "sending guest login<BR>\n"; socket_write ($socket, $in, strlen ($in)); echo "OK.\n"; echo "Reading response:\n\n"; while (socket_read ($socket, $out, 2048)) {
    echo ord($out);
} echo "Closing socket..."; socket_close ($socket); echo "OK.\n\n"; echo strlen($out); ?>

« previous php.general (#78258) next »