socket_write return wrong data length

From: Date: Tue, 09 Jun 2009 14:08:18 +0000
Subject: socket_write return wrong data length
Groups: php.general 
Request: Send a blank email to php-general+get-293803@lists.php.net to get a copy of this message
Hi all, I'm writting a little telnet client, but I've a problem with the socket_write function
        public function send($data){
                $datalen = strlen($data);
                $datawritten = 0;
                do {
                        $datawritten = socket_write($this->_tnsocket, $data, $datalen);
                        if( $datawritten === FALSE) {
                                echo __METHOD__." : ".socket_strerror(socket_last_error())."\n";
                                return (FALSE);
                        }
                        echo "Bytes written : ".$datawritten."\n";
                        $data = substr($data, $datawritten);
                        $datalen = strlen($data);
                } while($datawritten < $datalen);
                return (TRUE);
        }
When I use this function for writting a sample message of 4526 Bytes it returns : Bytes written : 4526 But it really wrotes only 1460 Bytes (verified with Wireshark). So my question is why socket_write returns me a wrong data length ? Thanks

« previous php.general (#293803) next »