Represents a single socket connection to a client IP address.
If a Netsocket is running in server mode then it will create a new ClientSocket object every time that a new connection is opened by a client. This is a very simple class that assists in the management of I/O between the client and 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 the NetSocket. If the #Feedback field is defined with a function, it will be called automatically whenever the state is changed. Note that the ClientSocket parameter will be NULL when the Feedback function is called. Note that in server mode this State value should not be used as it cannot reflect the state of all connected client sockets. Each ClientSocket carries its own independent State value for use instead.
|
The following actions are currently supported:
Read | Read incoming data from a client socket. | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ERR acRead(*Object, APTR Buffer, INT Length, 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, APTR Buffer, INT Length, 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. |
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 | In server mode the NetSocket will be set to MULTISTATE to indicate one or more client connections. |