Socket

php\net\Socket

Class Socket

Methods


__construct($host = null, $port = null)
Parameters:
  • $hostnull, string
  • $portnull, int
getOutput()

throws php\io\IOException

Returns:php\io\MiscStream
getInput()

throws php\io\IOException

Returns:php\io\MiscStream
getLocalAddress()
Returns:string
getAddress()
Returns:string
getLocalPort()
Returns:int
getPort()
Returns:int
close()

throws php\io\IOException

shutdownInput()

throws php\io\IOException

shutdownOutput()

throws php\io\IOException

isConnected()
Returns:bool
isClosed()
Returns:bool
isBound()
Returns:bool
isInputShutdown()
Returns:bool
isOutputShutdown()
Returns:bool
connect($hostname, $port, $timeout = null)

Connects this socket to the server

Parameters:
  • $hostnamestring
  • $portint
  • $timeoutnull, int
bind($hostname, $port)

Binds the socket to a local address.

throws php\net\SocketException

Parameters:
  • $hostnamestring
  • $portint
bindDefault()
setSoTimeout($timeout)

Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.

throws php\net\SocketException

Parameters:
  • $timeoutint
setSoLinger($on, $linger)

throws php\net\SocketException

Parameters:
  • $onbool
  • $lingerint
setReuseAddress($on)

Enable/disable the SO_REUSEADDR socket option.

throws php\net\SocketException

Parameters:
  • $onbool
setReceiveBufferSize($size)

throws php\net\SocketException

Parameters:
  • $sizeint
setTcpNoDelay($on)

throws php\net\SocketException

Parameters:
  • $onbool
setKeepAlive($on)

throws php\net\SocketException

Parameters:
  • $onbool
setOOBInline($on)

throws php\net\SocketException

Parameters:
  • $onbool
setSendBufferSize($size)

throws php\net\SocketException

Parameters:
  • $sizeint
setTrafficClass($tc)

Sets traffic class or type-of-service octet in the IP header for packets sent from this Socket.

Parameters:
  • $tcint
setPerformancePreferences($connectTime, $latency, $bandWidth)

Sets performance preferences for this ServerSocket.

! Not implemented yet for TCP/IP

Parameters:
  • $connectTimeint
  • $latencyint
  • $bandWidthint
sendUrgentData($data)

Send one byte of urgent data on the socket. The byte to be sent is the lowest eight bits of the data parameter.

throws php\net\SocketException

Parameters:
  • $dataint