socket_write
socket_write
Write to a socket
**socket_write** Socket $socket string $data $length
The function writes to the
from the given
.
socket_write``socket``data
socket
dataThe buffer to be written.
length
The optional parameter can specify an
alternate length of bytes written to the socket. If this length is
greater than 's length,
it is silently truncated to the length of .
length``data``data
Returns the number of bytes successfully written to the socketreturn.falseforfailure.
The error code can be retrieved with
. This code may be passed to
to get a textual explanation of the
error.
socket_last_error``socket_strerror
Opmerking: > It is perfectly valid for to return zero which means no bytes have been written. Be sure to use the operator to check for false in case of an error.
socket_write``===
Opmerking: > does not necessarily write all bytes from . It's valid that, depending on the network buffers etc., only a certain amount of data, even one byte, is written despite being longer. A loop must be used to ensure that the rest of is transmitted.
socket_write``data``data``data
socket_accept``socket_bind``socket_connect``socket_listen``socket_read``socket_strerror