Module: fathom/socket/tcp

This component provides APIs for communication over TCP.
Source:

Methods

(static) close(callback)

This function closes a TCP socket.
Parameters:
Name Type Description
callback function The callback Fathom invokes once the operation completes. On error, its only argument is a dictionary whose member "error" describes the problem that occurred.
Source:

(static) getHostIP(callback, socketid)

This function returns the IP address of the local endpoint of a given TCP connection.
Parameters:
Name Type Description
callback function The callback Fathom invokes either when an error has occurred or when data has arrived. When successful, its only argument is the local IP address. On error, its only argument is a dictionary whose member "error" describes the problem that occurred.
socketid integer The socket handle previously obtained from one of the opening functions.
Source:

(static) getPeerIP(callback, socketid)

This function returns the IP address of the remote endpoint of a given TCP connection.
Parameters:
Name Type Description
callback function The callback Fathom invokes either when an error has occurred or when data has arrived. When successful, its only argument is the remote IP address. On error, its only argument is a dictionary whose member "error" describes the problem that occurred.
socketid integer The socket handle previously obtained from one of the opening functions.
Source:

(static) openReceiveSocket(callback, port, reuse)

This function creates a TCP socket, binds it locally to the given port, and listens for connections.
Parameters:
Name Type Description
callback function The callback Fathom invokes once the operation completes. When successful, its only argument is a socket descriptor. On error, its only argument is a dictionary whose member "error" describes the problem that occurred.
port integer Port to listen on.
reuse boolean Reuse the port.
Source:

(static) openSendSocket(callback, destip, destport)

This function creates a TCP socket and connects it to the given destination.
Parameters:
Name Type Description
callback function The callback Fathom invokes once the operation completes. When successful, its only argument is a socket descriptor. On error, its only argument is a dictionary whose member "error" describes the problem that occurred.
destip string IP address to connect to.
destport integer Port to connect to.
Source:

(static) recv(callback, socketid, asstring, timeout, size)

This function receives data on a TCP connection.
Parameters:
Name Type Description
callback function The callback Fathom invokes either when an error has occurred or when data has arrived. When successful, its only argument is the received data chunk. On error, its only argument is a dictionary whose member "error" describes the problem that occurred.
socketid integer The socket handle previously obtained from one of the opening functions.
asstring boolean Return the bytes as string (default false).
timeout integer Time to wait for the data (in ms), < 0 waits forever, 0 no wait (default).
size integer Number of bytes to read (or 0 to ignore - default).
Source:

(static) send(callback, socketid, data)

This function sends data over the TCP connection identified by the given socket ID.
Parameters:
Name Type Description
callback function The callback Fathom invokes once the send call returns.
socketid integer The socket handle previously obtained from one of the opening functions.
data string The data chunk to transmit.
Source: