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 | struct NetClient * | Parent client structure | |
ClientData | APTR | Free for user data storage. | |
ConnectTime | BIGINT | System time for the creation of this socket | |
Incoming | FUNCTION | Callback for data being received from the socket | |
MsgLen | INT | Length of the current incoming message | |
Next | *ClientSocket | Next socket in the chain | |
Outgoing | FUNCTION | Callback for data being sent over the socket | |
Prev | *ClientSocket | Previous socket in the chain | |
ReadCalled | INT | TRUE if the Read action has been called |
The following actions are currently supported:
Name | Comment | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Read | Read incoming data from a client socket. | |||||||||||||||||
ERR acRead(*Object, APTR Buffer, LONG Length, LONG *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, LONG Length, LONG 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. |
The following methods are currently supported:
Name | Comment | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ReadClientMsg | Read a message from the socket. | ||||||||||||||||||||||||
ERR cs::ReadClientMsg(OBJECTPTR Object, APTR * Message, LONG * Length, LONG * Progress, LONG * CRC)
This method reads messages that have been sent to the socket using Parasol Message Protocols. Any message sent with the WriteClientMsg() method will conform to this protocol, thus simplifying message transfers between programs based on the core platform at either point of the network link. This method never returns a successful error code unless an entire message has been received from the sender. Error Codes
| |||||||||||||||||||||||||
WriteClientMsg | Writes a message to the socket. | ||||||||||||||||||||||||
ERR cs::WriteClientMsg(OBJECTPTR Object, APTR Message, LONG Length)
Messages can be written to sockets with the WriteClientMsg method and read back by the receiver with ReadClientMsg(). The message data is sent through the Write() action, so the standard process will apply (the message will be queued and does not block if buffers are full). Error Codes
|
Simple data storage class utilised by NetSocket to represent a client machine/IP.
Field | Type | Description |
---|---|---|
IP | char | IP address in 4/8-byte format |
Next | struct NetClient * | Next client in the chain |
Prev | struct NetClient * | Previous client in the chain |
NetSocket | objNetSocket * | Reference to the parent socket |
Sockets | objClientSocket * | Pointer to a list of sockets opened with this client. |
ClientData | APTR | Free for user data storage. |
TotalSockets | LONG | Count of all created sockets |
Class Info | |
---|---|
ID | ID_CLIENTSOCKET |
Category | Network |
Include | modules/clientsocket.h |
Version | 1 |