ks_socket.c File Reference

libkarmaclient abstract socket type and documentation. More...

Go to the source code of this file.


Detailed Description

libkarmaclient abstract socket type and documentation.

This file contains documentation about socket implementations for libkarmaclient. Concrete socket implementations included with this library are found in ks_socket_posix.c.

Timeouts and the Karma Query Server
The karma server has an internal trigger (currently set at 2 seconds), after which it will respond with whatever data it has collected. So, when choosing timeout values, you must start with a timeout greater than the expected maximum network latency and finish with a value greater than the server timeout plus the expected maximum network latency. This means that there will be an early retry for a dropped packet, but if the query is complex, the client is guaranteed to wait "long enough" for a response.

We suggest starting with a timeout of 1 second, and treble it for 3 retries, to finish with a timeout of 9 seconds. See also ks_socket_ask().

Packet reordering
Responses are not ordered. The client must use query ids to match the responses up with the correct queries. It is usually necessary to use a client-side response cache to achieve this.

If you stream requests at high speed over a socket, the server may send responses back over a socket in a different order to order in which the requests were sent. This applies to both TCP and UDP modes.

If you wait for each response on a particular socket before sending the next query, then you can nearly lock-step the queries, but if a response is apparently "lost", it may still appear later, so this strategy is not totally reliable.

There is packet reordering code in ks_socket_posix.c which sorts this out. There is also a "simple version" (lines 570-591) in a comment which is a non-pthread explanation of the more complex code below.

Definition in file ks_socket.c.


Generated on Wed May 9 01:01:57 2007 for libkarmaclient by  doxygen 1.5.1