PHP Manual
Prev |  | Next

# socket_read

(PHP 4 >= 4.1.0)

socket_read -- Read from a socket

## Description

``int socket_read` (resource socket_des, string buffer, int length [, int type])`

Warning
This function is EXPERIMENTAL. The behaviour of this function, the name of this function, and anything else documented about this function may change in a future release of PHP without notice. Be warned and use this function at your own risk.

The function socket_read() reads from socket `socket_des`created by the socket_accept() function into `buffer` the number of bytes set by `length`. Otherwise you can use \n, \t or \0 to end reading. Returns number of bytes that have been read.

Optional `type` parameter is a named constant:

- PHP_BINARY_READ - use the system socket_read() (Default in PHP >= 4.1.0)

- PHP_NORMAL_READ - reading stops at \n or \r. (Default in PHP <= 4.0.6)

See also socket_accept(), socket_bind(), socket_connect(), socket_listen(), socket_strerror(), socket_get_status() and socket_write().

Prev | Home | Next
socket_listen | Up | socket_create