Documentation

Net::Socket

Class

A non-blocking TCP socket.

Methods

Start a connection to the given host and port. This is non-blocking and will immediately return. Use IsReady() to wait for the connection to be ready.

Returns bool

Starts listening on the given host and port.

Returns bool

Starts listening on the given port using 0.0.0.0 as the host. Note that this will open up the port to the LAN, which may not be what you want.

Returns bool

Closes the socket.

When this socket is listening, attempts to accept a client connection if one is trying to connect. If there is, it will be returned. If no client is waiting, this will return null.

Returns Net::Socket@

Get the host IP address associated with this socket.

Returns string
Deprecated

This method is deprecated and should not be used. Consider using IsReady(), IsHungUp(), or Available() instead, depending on your use-case.

Returns bool
Deprecated

This method is deprecated and should not be used. Use IsReady() instead.

Returns bool

Returns true if the socket is ready to be used.

Returns bool

Returns true if the socket state currently has the hangup flag. Note that this flag may be set while there is still data in the buffer that can be read.

Returns bool

Returns the number of bytes available to be read from the socket buffer.

Returns int

Reads the given number of bytes and return it as a string.

Returns string

Reads the given number of bytes and return it as a MemoryBuffer.

Returns MemoryBuffer@

Writes the given string to the socket as-is. Returns false if the write did not succeed. Note that this behavior differs from Write(const string &in).

Returns bool

Attempts to read up until the next newline character, and outputs the string (including the newline character) in str. If no newline character is encountered, it will return false, leave str unmodified, and no bytes will be consumed from the buffer.

Returns bool

Writes a line of text to the socket. Returns false if the write did not succeed. This behaves the same as WriteRaw(), except a newline is appended.

Returns bool

Reads an 8 bit signed integer from the buffer.

Returns int8

Reads a 16 bit signed integer from the buffer.

Returns int16

Reads a 32 bit signed integer from the buffer.

Returns int

Reads a 64 bit signed integer from the buffer.

Returns int64

Reads an 8 bit unsigned integer from the buffer.

Returns uint8

Reads a 16 bit unsigned integer from the buffer.

Returns uint16

Reads a 32 bit unsigned integer from the buffer.

Returns uint

Reads a 64 bit unsigned integer from the buffer.

Returns uint64

Reads a 32 bit float from the buffer.

Returns float

Reads a 64 bit float from the buffer.

Returns double

Reads a string length from the buffer as a 32 bit unsigned integer, followed by the actual string. This complements Write(const string &in).

Returns string

Writes an 8 bit signed integer to the socket. Returns false if the write did not succeed.

Returns bool

Writes a 16 bit signed integer to the socket. Returns false if the write did not succeed.

Returns bool

Writes a 32 bit signed integer to the socket. Returns false if the write did not succeed.

Returns bool

Writes a 64 bit signed integer to the socket. Returns false if the write did not succeed.

Returns bool

Writes an 8 bit unsigned integer to the socket. Returns false if the write did not succeed.

Returns bool

Writes a 16 bit unsigned integer to the socket. Returns false if the write did not succeed.

Returns bool

Writes a 32 bit unsigned integer to the socket. Returns false if the write did not succeed.

Returns bool

Writes a 64 bit unsigned integer to the socket. Returns false if the write did not succeed.

Returns bool

Writes a 32 bit float to the socket. Returns false if the write did not succeed.

Returns bool

Writes a 64 bit double to the socket. Returns false if the write did not succeed.

Returns bool

Writes a 32 bit unsigned integer for the length of the string to the socket, followed by the actual string. Returns false if the write did not succeed. Note that this behavior differs from WriteRaw().

Returns bool

Reads a number of bytes from the given MemoryBuffer and writes them to the socket.

Returns bool