\D3strukt0r\Votifier\Client
Socket¶
-
class
D3strukt0r\Votifier\Client\Socket¶ The class ServerConnection is used to create a connection to a server.
-
private property
$socket¶ resource — The connection to the server
-
public
__destruct()¶ Closes the connection when the object is destroyed.
-
public
open($host, $port)¶ Creates the ServerConnection object.
Parameters: - $host (string) – The hostname or IP address
- $port (int) – The port of Votifier
Throws: D3strukt0r\Votifier\Client\Exception\Socket\NoConnectionException— If connection couldn’t be established
-
public
write($string)¶ Sends a string to the server.
Parameters: - $string (string) – The string which should be sent to the server
Throws: D3strukt0r\Votifier\Client\Exception\Socket\NoConnectionException— If connection has not been set upThrows: D3strukt0r\Votifier\Client\Exception\Socket\PackageNotSentException— If there was an error sending the package
-
public
read([$length = 64]) → string¶ Reads a string which is being received from the server.
Parameters: - $length (int) – [optional] The length of the requested string
Throws: D3strukt0r\Votifier\Client\Exception\Socket\NoConnectionException— If connection has not been set upThrows: D3strukt0r\Votifier\Client\Exception\Socket\PackageNotReceivedException— If there was an error receiving the packageReturns: string — Returns the string received from the server
-
private property