|
Zen API
|
Represents a TCP client.
Inheritance diagram for kTcpClient:Public Member Functions | |
| kAlloc | kObject_Alloc (kObject object) |
| Gets the memory allocator associated with this object. More... | |
| kStatus | kObject_Clone (kObject *object, kObject source, kAlloc allocator) |
| Constructs a new object by copying an existing object, including any aggregated child elements. More... | |
| kStatus | kObject_Destroy (kObject object) |
| Destroys the object. More... | |
| kStatus | kObject_Dispose (kObject object) |
| Destroys the object and any aggregated child elements. More... | |
| kBool | kObject_Equals (kObject object, kObject other) |
| Determines whether the object is equal to another object. More... | |
| kSize | kObject_HashCode (kObject object) |
| Gets a hash code representing the state of this object. More... | |
| kBool | kObject_Is (kObject object, kType type) |
| Determines whether this object is an instance of the specified type. More... | |
| kBool | kObject_IsShared (kObject object) |
| Reports whether the object is currently shared (reference count greater than one). More... | |
| kStatus | kObject_SetPool (kObject object, kObjectPool pool) |
| Sets the object pool associated with this object. More... | |
| kStatus | kObject_Share (kObject object) |
| Increments the reference count associated with this object. More... | |
| kSize | kObject_Size (kObject object) |
| Estimates the memory consumed by this object, including any aggregated child elements. More... | |
| kType | kObject_Type (kObject object) |
| Returns the type of the object. More... | |
| k64u | kStream_BytesRead (kStream stream) |
| Reports the number of bytes read from this stream. More... | |
| k64u | kStream_BytesWritten (kStream stream) |
| Reports the number of bytes written to this stream. More... | |
| kStatus | kStream_ClearStats (kStream stream) |
| Clears stream statistics (e.g. More... | |
| kStatus | kStream_Copy (kStream stream, kStream source, kSize size) |
| Copies the specified number of bytes from one stream to another. More... | |
| kStatus | kStream_CopyEx (kStream stream, kStream source, kSize size, kCallbackFx progress, kPointer context) |
| Copies the specified number of bytes from one stream to another, with progress feedback. More... | |
| kStatus | kStream_Flush (kStream stream) |
| Flushes buffered writes to the underlying medium. More... | |
| kStatus | kStream_Read (kStream stream, void *buffer, kSize size) |
| Reads the specified number of bytes from the stream. More... | |
| kStatus | kStream_ReadSome (kStream stream, void *buffer, kSize minCount, kSize maxCount, kSize *bytesRead) |
| Reads up to the specified number of bytes from the stream. More... | |
| kStatus | kStream_Seek (kStream stream, k64s offset, kSeekOrigin origin) |
| Moves the read/write pointer to the specified location. More... | |
| kStatus | kStream_Write (kStream stream, const void *buffer, kSize size) |
| Writes the specified number of bytes to the stream. More... | |
| kSize | kTcpClient_Available (kTcpClient client) |
| Returns the number of bytes currently enqueued and available for reading. More... | |
| kStatus | kTcpClient_Cancel (kTcpClient client) |
| Cancels any pending I/O operations. More... | |
| kStatus | kTcpClient_Connect (kTcpClient client, kIpAddress address, k32u port, k64u timeout) |
| Connects to a remote end point. More... | |
| kStatus | kTcpClient_Construct (kTcpClient *client, kIpVersion ipVersion, kAlloc allocator) |
| Constructs a TCP client object. More... | |
| kStatus | kTcpClient_LocalEndPoint (kTcpClient client, kIpEndPoint *endPoint) |
| Returns the local end point for a connected client. More... | |
| kStatus | kTcpClient_RemoteEndPoint (kTcpClient client, kIpEndPoint *endPoint) |
| Returns the remote end point for a connected client. More... | |
| kStatus | kTcpClient_SetCancelHandler (kTcpClient client, kCallbackFx function, kPointer receiver) |
| Sets a cancel query handler, which can be used to asynchronously terminate read/write operations. More... | |
| kStatus | kTcpClient_SetReadBuffers (kTcpClient client, kSSize socketSize, kSSize clientSize) |
| Sets the size of read buffers. More... | |
| kStatus | kTcpClient_SetReadTimeout (kTcpClient client, k64u timeout) |
| Sets the timeout duration for blocking read operations. More... | |
| kStatus | kTcpClient_SetWriteBuffers (kTcpClient client, kSSize socketSize, kSSize clientSize) |
| Sets the size of write buffers. More... | |
| kStatus | kTcpClient_SetWriteTimeout (kTcpClient client, k64u timeout) |
| Sets the timeout duration for blocking write operations. More... | |
| kSocket | kTcpClient_Socket (kTcpClient client) |
| Returns the underlying kSocket object. More... | |
| kStatus | kTcpClient_Status (kTcpClient client) |
| Reports any internal errors that will prevent success of future communication attempts. More... | |
| kStatus | kTcpClient_Wait (kTcpClient client, k64u timeout) |
| Waits until the client has bytes to read or until the specified timeout period elapses. More... | |
Gets the memory allocator associated with this object.
Most objects are constructed with an allocator, which is used to allocate the memory required by the object. Objects retain a reference to this allocator to enable further allocations and to free memory when the object is destroyed.
| object | Object. |
Constructs a new object by copying an existing object, including any aggregated child elements.
If the source object is an object collection (e.g. kArrayList<kString>), any aggregated child objects are also cloned. In this case, the kObject_Dispose method can be used to free the cloned collection and its associated elements.
This method will fail if the source object (or an aggregated child element) does not support cloning.
| object | Receives the constructed object. |
| source | Source object. |
| allocator | Memory allocator (or kNULL for default). |
Destroys the object.
The kObject_Destroy method destroys the object itself and any resources that are owned by the object. See Object Destruction for more information.
When an object is destroyed (or disposed), its reference count is decremented. The object is only truly destroyed when the reference count reaches zero. See Reference Counting for more information.
| object | Object (or kNULL). |
Destroys the object and any aggregated child elements.
The kObject_Dispose method destroys the object itself, any resources that are owned by the object, and if the object represents a collection of objects, any child objects in the collection. See Object Destruction for more information.
When an object is destroyed (or disposed), its reference count is decremented. The object is only truly destroyed when the reference count reaches zero. See Reference Counting for more information.
| object | Object (or kNULL). |
Determines whether the object is equal to another object.
By default, objects are compared by reference; objects are considered equal if the given handles refer to the same object instance. However, some classes override the Equals method to provide a more meaningful comparison (e.g. kString).
| object | Object. |
| other | Object for comparison. |
Gets a hash code representing the state of this object.
By default, objects return a hash code based on the object handle value. However, some classes override the HashCode method to provide a more useful hash (e.g. kString).
| object | Object. |
Determines whether this object is an instance of the specified type.
This function compares the type of this object with the given type. An object is considered to be an instance of a given type if a) the type represents a class and this object inherits from (or instantiates) that class, or b) the type represents an interface and this object implements the interface.
| object | Object. |
| type | Type. |
Reports whether the object is currently shared (reference count greater than one).
Objects are initialized with a reference count of one. The kObject_Share method can be used to increment the reference count. The kObject_Destroy and kObject_Dispose methods decrease the reference count, and when the reference count reaches zero, the object is actually destroyed/disposed.
This method can be used to determine if the reference count of an object is currently greater than one.
This method is thread-safe.
| object | Object. |
|
inherited |
Sets the object pool associated with this object.
Object pools can be used to implement custom lifecycle management. If an object has an assigned pool, then the kObjectPool_Reclaim method will be called just prior to destruction, to provide an opportunity for the object to be reclaimed.
| object | Object. |
| pool | Pool object (or kNULL to clear the pool assignment). |
Increments the reference count associated with this object.
This method is thread-safe.
| object | Object. |
Estimates the memory consumed by this object, including any aggregated child elements.
This method can be optionally overridden by kObject-derived classes to report the amount of memory consumed by an object. The default implementation reports only the size of the class instance (additional allocations performed by the class are excluded).
| object | Object. |
Returns the type of the object.
Each object is an instance of a specific class type. The type handle returned by this function can be used to learn about the class.
| object | Object. |
Reports the number of bytes read from this stream.
| stream | Stream object. |
Reports the number of bytes written to this stream.
| stream | Stream object. |
Clears stream statistics (e.g.
BytesRead, BytesWritten).
| stream | Stream object. |
Copies the specified number of bytes from one stream to another.
| stream | Destination stream. |
| source | Source stream. |
| size | Count of bytes to be copied. |
|
inherited |
Copies the specified number of bytes from one stream to another, with progress feedback.
The specified callback will be invoked to provide feedback on the progress of the operation. The callback 'args' parameter will receive a k32u value representing the percentage completed. The callback is guaranteed to be called at least once if the operation is successful, with a progress value of 100%.
| stream | Destination stream. |
| source | Source stream. |
| size | Count of bytes to be copied. |
| progress | Optional progress callback (can be kNULL). |
| context | Callback context. |
Flushes buffered writes to the underlying medium.
| stream | Stream object. |
Reads the specified number of bytes from the stream.
| stream | Stream object. |
| buffer | Destination for bytes that are read. |
| size | Count of bytes to read. |
|
inherited |
Reads up to the specified number of bytes from the stream.
| stream | Stream object. |
| buffer | Destination for bytes that are read. |
| minCount | Minimum count of bytes to read. |
| maxCount | Maximum count of bytes to read. |
| bytesRead | Receives count of bytes read. |
|
inherited |
Moves the read/write pointer to the specified location.
| stream | Stream object. |
| offset | Offset by which to adjust the read/write pointer. |
| origin | Origin to which movement is relative (i.e. begin, current, end). |
Writes the specified number of bytes to the stream.
| stream | Stream object. |
| buffer | Bytes to be written to the stream. |
| size | Count of bytes to be written. |
| kSize kTcpClient_Available | ( | kTcpClient | client | ) |
Returns the number of bytes currently enqueued and available for reading.
This function returns the count of bytes enqueued in the client's internal read buffer. This does not include any data enqueued in the underlying socket's read buffer.
| client | TCP client object. |
| kStatus kTcpClient_Cancel | ( | kTcpClient | client | ) |
Cancels any pending I/O operations.
kTcpClient_SetCancelHandler and kTcpClient_Cancel represent alternative approaches to I/O cancellation; use one or the other approach, but not both.
This method is thread-safe.
| kStatus kTcpClient_Connect | ( | kTcpClient | client, |
| kIpAddress | address, | ||
| k32u | port, | ||
| k64u | timeout | ||
| ) |
Connects to a remote end point.
A connection can be established only once per kTcpClient object.
| client | TCP client object. |
| address | The remote IP address. |
| port | The remote port number. |
| timeout | Timeout interval, in microseconds. |
| kStatus kTcpClient_Construct | ( | kTcpClient * | client, |
| kIpVersion | ipVersion, | ||
| kAlloc | allocator | ||
| ) |
Constructs a TCP client object.
| client | Destination for the constructed object handle. |
| ipVersion | Internet Protocol version. |
| allocator | Memory allocator (or kNULL for default). |
| kStatus kTcpClient_LocalEndPoint | ( | kTcpClient | client, |
| kIpEndPoint * | endPoint | ||
| ) |
Returns the local end point for a connected client.
| client | TCP client object. |
| endPoint | Local end point. |
| kStatus kTcpClient_RemoteEndPoint | ( | kTcpClient | client, |
| kIpEndPoint * | endPoint | ||
| ) |
Returns the remote end point for a connected client.
| client | TCP client object. |
| endPoint | Remote end point. |
| kStatus kTcpClient_SetCancelHandler | ( | kTcpClient | client, |
| kCallbackFx | function, | ||
| kPointer | receiver | ||
| ) |
Sets a cancel query handler, which can be used to asynchronously terminate read/write operations.
kTcpClient_SetCancelHandler and kTcpClient_Cancel represent alternative approaches to I/O cancellation; use one or the other approach, but not both.
| client | TCP client object. |
| function | Callback function. |
| receiver | Callback context. |
| kStatus kTcpClient_SetReadBuffers | ( | kTcpClient | client, |
| kSSize | socketSize, | ||
| kSSize | clientSize | ||
| ) |
Sets the size of read buffers.
Socket buffers decouple the sender and receiver, so that the sender does not need to block while waiting for the receiver to receive all bytes. Client buffers improve the efficiency of the client when performing several small read operations.
| client | TCP client object. |
| socketSize | Size of the read buffer maintained by the underlying socket (-1 to leave unchanged). |
| clientSize | Size of the read buffer maintained by the client object (-1 to leave unchanged). |
| kStatus kTcpClient_SetReadTimeout | ( | kTcpClient | client, |
| k64u | timeout | ||
| ) |
Sets the timeout duration for blocking read operations.
By default, kTcpClient objects do not use a timeout interval and can block indefinitely.
| client | TCP client object. |
| timeout | Timeout value, in microseconds. |
| kStatus kTcpClient_SetWriteBuffers | ( | kTcpClient | client, |
| kSSize | socketSize, | ||
| kSSize | clientSize | ||
| ) |
Sets the size of write buffers.
Socket buffers decouple the sender and receiver, so that the sender does not need to block while waiting for the receiver to receive all bytes. Client buffers improve the efficiency of the client when performing several small write operations.
By default, the client buffer size is zero and the socket buffer size is determined by the underlying operating system.
| client | TCP client object. |
| socketSize | Size of the write buffer maintained by the underlying socket (-1 to leave unchanged). |
| clientSize | Size of the write buffer maintained by the client object (-1 to leave unchanged). |
| kStatus kTcpClient_SetWriteTimeout | ( | kTcpClient | client, |
| k64u | timeout | ||
| ) |
Sets the timeout duration for blocking write operations.
By default, kTcpClient objects do not use a timeout interval and can block indefinitely.
| client | TCP client object. |
| timeout | Timeout value, in microseconds. |
| kSocket kTcpClient_Socket | ( | kTcpClient | client | ) |
| kStatus kTcpClient_Status | ( | kTcpClient | client | ) |
Reports any internal errors that will prevent success of future communication attempts.
| client | TCP client object. |
| kStatus kTcpClient_Wait | ( | kTcpClient | client, |
| k64u | timeout | ||
| ) |
Waits until the client has bytes to read or until the specified timeout period elapses.
This function will return kERROR_TIMEOUT in the event that the client is not ready for reading by the end of the timeout period.
| client | TCP client object. |
| timeout | Timeout interval, in microseconds. |