Interface TCPSocket
access this type via: net.TCPSocket (provides, requires or uses)
--- extends:Stream
Communicate over the TCP network protocol. New connections can be established either using 'connect' (for a client) or by using 'accept' (for a server, in conjunction with a TCPServerSocket instance).
Events
sendWait(Data d)
Functions
bool connect(char address[], int port)
bool accept(TCPServerSocket server)
void disconnect()
NetworkEndpoint getRemoteEndpoint()
NetworkEndpoint getLocalEndpoint()
bool setNonBlocking(optional storeData sendWaitData)
int sendBuffer()
int getBufferUnsent()
bool connected()
Events
sendWait In non-blocking mode, this event is fired when a send() fails due to the socket not being ready. The socket should be set for write-ability notification in e.g. a TCPMonitor, then when a writeable notification arrives, sendBuffer() should be called to send pending bytes.
bool connect(char address[], int port)
Connect to the given TCP server.
bool accept(TCPServerSocket server)
Establish a TCP connection by accepting a new client via a TCP server socket.
void disconnect()
Disconnect (terminate) this TCP connection.
NetworkEndpoint getRemoteEndpoint()
Get the endpoint details of the remote end of this TCP connection.
NetworkEndpoint getLocalEndpoint()
Get the endpoint details of the local end of this TCP connection.
bool setNonBlocking(optional storeData sendWaitData)
Switch the socket to non-blocking mode. In this mode, calls to recv() will always return 'immediately' but may read no data. Non-blocking TCP sockets are normally used with net.TCPMonitor. The optional data instance is delivered via any sendWait() events.
int sendBuffer()
In non-blocking mode only, send any pending bytes; this should be called after a write-ability notification has been received from a TCPMonitor.
int getBufferUnsent()
In non-blocking mode only, check how many bytes are in the send buffer pending write-ability.
bool connected()
Test whether or not this socket is connected (this is useful only in non-blocking mode, to determine whether a null return from recv() is temporary or terminal).