note 38817 added to function.socket-write

From: Date: Wed, 07 Jan 2004 19:49:07 +0000
Subject: note 38817 added to function.socket-write
Groups: php.notes 
Request: Send a blank email to php-notes+get-63105@lists.php.net to get a copy of this message
I have seen a lot of people misusing socket_write(). They assume that all the data will be transferred in one call. Here is the proper way to send data using socket_write(). $totalToSend = strlen($data); $sent = 0; while($sent < $totalToSend) { $i = socket_write($socket,$data); if($i === FALSE) { die('Error: '.socket_strerror(socket_last_error())."\n"); } $sent += $i; $data = substr($data,$i); } ---- Manual Page -- http://www.php.net/manual/en/function.socket-write.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38817 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38817&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38817&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#63105) next »