Writing

socket_write($r, $s [, $i]) writes $i bytes of data from $s on the socket $r. This function returns the number of bytes written, or FALSE on failure.

socket_send($r, $s, $i1, $i2) sends $i2 bytes of data from $s to the socket $r using the flags $i2.
socket_sendto($r, $s1, $i1, $i2, $s2 [, $i3]) sends $i1 bytes of data from $s1 through the socket $r to port $i3 at the address $s2.
socket_sendmsg ($r, $arr [,$i2]) sends the message in $arr through the socket $r using the flags $i2. These functions return the number of bytes sent, or FALSE on error. $i2 is a combination of:

MSG_OOB
Sends out-of-band data.
MSG_EOR Indicates a record mark. The sent data completes the record.
MSG_EOF Closes the sender side of the socket and includes an appropriate notification of this at the end of the sent data. The sent data completes the transaction.
MSG_DONTROUTE Bypasses routing, uses direct interface.

socket_shutdown($r [,$i]) shuts down a socket for receiving, sending, or both. $i can be 0 (stops reading), 1 (stops writing), or 2 (stops reading and writing).