Represents a single socket connection to a client IP address.
When a NetServer accepts a TCP connection, it creates a new ClientSocket object for that connection. This is a very simple class that assists in the management of I/O between the accepted client and the server.
The ClientSocket class consists of the following fields:
Access | Name | Type | Comment | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Client | *NetClient | Parent client object (IP address). | |||||||||||||||
| ClientData | APTR | Available for client data storage. | |||||||||||||||
| ConnectTime | INT64 | System time for the creation of this socket. | |||||||||||||||
| Next | *ClientSocket | Next socket in the chain. | |||||||||||||||
| Prev | *ClientSocket | Previous socket in the chain. | |||||||||||||||
| State | NTC | The current connection state of the ClientSocket object. | |||||||||||||||
The State reflects the connection state of this accepted client socket. If the parent NetServer has a #Feedback function, it will be called automatically whenever the state is changed.
| |||||||||||||||||
The following actions are currently supported:
| Deactivate | Disconnects the socket and changes the State to DISCONNECTED. | |||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Read | Read incoming data from a client socket. | |||||||||||||||||
ERR acRead(*Object, std::span<int8_t> Buffer, INT *Result)
The Read() action will read incoming data from the socket and write it to the provided buffer. If the socket connection is safe, success will always be returned by this action regardless of whether or not data was available. Almost all other return codes indicate permanent failure, and the socket connection will be closed when the action returns. Error Codes
| ||||||||||||||||||
| Write | Writes data to the socket. | |||||||||||||||||
ERR acWrite(*Object, std::span<const int8_t> Buffer, INT *Result)
Write raw data to a client socket with this action. Write connections are buffered, so any data overflow generated in a call to this action will be buffered into a software queue. Resource limits placed on the software queue are governed by the NetSocket⇒MsgLimit value. Assuming no errors occur, the reported result will always reflect the length of the incoming buffer. | ||||||||||||||||||
NetSocket states
| Name | Description |
|---|---|
| NTC::CONNECTED | There is an active connection at present. |
| NTC::CONNECTING | A connection is being established. |
| NTC::DISCONNECTED | There is no connection. |
| NTC::HANDSHAKING | An SSL connection is being established. |
| NTC::MULTISTATE | A NetServer reports MULTISTATE because accepted ClientSocket objects track their own states. |
| NTC::RESOLVING | The host name is being resolved. |