|
| typedef void(* | tr_close_fp )(void *socket) |
| |
| typedef void(* | tr_free_fp )(struct tr_socket *tr_sock) |
| |
| typedef const char *(* | tr_ident_fp )(void *socket) |
| |
| typedef int(* | tr_open_fp )(void *socket) |
| |
| typedef int(* | tr_recv_fp )(const void *socket, void *pdu, const size_t len, const time_t timeout) |
| |
| typedef int(* | tr_send_fp )(const void *socket, const void *pdu, const size_t len, const time_t timeout) |
| |
|
| void | tr_close (struct tr_socket *socket) |
| |
| void | tr_free (struct tr_socket *socket) |
| |
| const char * | tr_ident (struct tr_socket *socket) |
| |
| int | tr_open (struct tr_socket *socket) |
| |
| int | tr_recv (const struct tr_socket *socket, void *buf, const size_t len, const time_t timeout) |
| |
| int | tr_recv_all (const struct tr_socket *socket, const void *buf, const size_t len, const time_t timeout) |
| |
| int | tr_send (const struct tr_socket *socket, const void *pdu, const size_t len, const time_t timeout) |
| |
| int | tr_send_all (const struct tr_socket *socket, const void *pdu, const size_t len, const time_t timeout) |
| |
Before using the transport socket, a tr_socket must be initialized based on a protocol-dependent init function (e.g., tr_tcp_init()).
The tr_* functions call the corresponding function pointers, which are passed in the tr_socket struct, and forward the remaining arguments.
| typedef void(* tr_close_fp)(void *socket) |
A function pointer to a technology specific close function.
- See Also
- tr_close
| typedef void(* tr_free_fp)(struct tr_socket *tr_sock) |
A function pointer to a technology specific free function. All memory associated with the tr_socket will be freed.
- See Also
- tr_free
| typedef const char*(* tr_ident_fp)(void *socket) |
A function pointer to a technology specific info function.
- See Also
- tr_send
| typedef int(* tr_open_fp)(void *socket) |
A function pointer to a technology specific open function.
- See Also
- tr_open
| typedef int(* tr_recv_fp)(const void *socket, void *pdu, const size_t len, const time_t timeout) |
A function pointer to a technology specific recv function.
- See Also
- tr_recv
| typedef int(* tr_send_fp)(const void *socket, const void *pdu, const size_t len, const time_t timeout) |
A function pointer to a technology specific send function.
- See Also
- tr_send
The return values for tr_ functions.
| Enumerator |
|---|
| TR_SUCCESS |
Operation was successfull.
|
| TR_ERROR |
Error occured.
|
| TR_WOULDBLOCK |
No data is available on the socket.
|
| TR_INTR |
Call was interrupted from a signal
|
| TR_CLOSED |
Connection closed
|
Close the socket connection.
- Parameters
-
| [in] | socket | Socket that will be closed. |
Deallocates all memory that the passed socket uses. Socket have to be closed before.
- Parameters
-
| [in] | socket | which will be freed. |
| const char* tr_ident |
( |
struct tr_socket * |
socket | ) |
|
|
inline |
Returns an identifier for the socket endpoint, eg host:port.
- Parameters
-
| [in] | socket | return Pointer to a \0 terminated String return NULL on error |
Establish the connection.
- Parameters
-
| [in] | socket | Socket that will be used. |
- Returns
- TR_SUCCESS On success.
-
TR_ERROR On error.
| int tr_recv |
( |
const struct tr_socket * |
socket, |
|
|
void * |
buf, |
|
|
const size_t |
len, |
|
|
const time_t |
timeout |
|
) |
| |
|
inline |
Receives <= len Bytes data from the socket.
- Parameters
-
| [in] | socket | Socket that will be used. |
| [out] | buf | Received data, must be an allocated memory area of >=pdu_len bytes. |
| [in] | len | Size of pdu in Bytes. |
| [in] | timeout | Max. seconds the function will block till len data was received. |
- Returns
- >0 Number of Bytes read.
-
TR_ERROR On error.
-
TR_WOULDBLOCK If no data was available at the socket before the timeout expired.
Referenced by tr_recv_all().
| int tr_recv_all |
( |
const struct tr_socket * |
socket, |
|
|
const void * |
buf, |
|
|
const size_t |
len, |
|
|
const time_t |
timeout |
|
) |
| |
Repeatly calls tr_recv(..) till len Bytes were received, the timeout expired or an error occured.
- Parameters
-
| [in] | socket | Socket that will be used. |
| [out] | buf | Received data, must be an allocated memory area of >=len bytes. |
| [in] | len | Size of pdu in Bytes. |
| [in] | timeout | Max. seconds the functions should try to receive len data till it returns. |
- Returns
- >0 Number of Bytes received.
-
TR_ERROR On error.
-
TR_WOULDBLOCK If send would block.
References tr_recv().
| int tr_send |
( |
const struct tr_socket * |
socket, |
|
|
const void * |
pdu, |
|
|
const size_t |
len, |
|
|
const time_t |
timeout |
|
) |
| |
|
inline |
Send <= len Bytes data over the socket.
- Parameters
-
| [in] | socket | Socket that will be used. |
| [out] | pdu | Data that will be be sent. |
| [in] | len | Size of pdu in Bytes. |
| [in] | timeout | Max. seconds the function should try to send the data till it returns. |
- Returns
- >0 Number of Bytes sent.
-
TR_ERROR On error.
Referenced by tr_send_all().
| int tr_send_all |
( |
const struct tr_socket * |
socket, |
|
|
const void * |
pdu, |
|
|
const size_t |
len, |
|
|
const time_t |
timeout |
|
) |
| |
Repeatly calls tr_send(..) till len Bytes were sent, the timeout expired or an error occured.
- Parameters
-
| [in] | socket | Socket that will be used. |
| [out] | pdu | Data that will be be sent. |
| [in] | len | Size of pdu in Bytes. |
| [in] | timeout | Max. seconds the functions should try to send pdu till it returns. |
- Returns
- >0 Number of Bytes sent.
-
TR_ERROR On Error.
-
TR_WOULDBLOCK If send would block.
References tr_send().