2 * Summary: Server IO, Not public!
4 * Copy: See Copyright for the status of this software.
9 #ifndef LIBMEMCACHED_MEMCACHED_IO_H
10 #define LIBMEMCACHED_MEMCACHED_IO_H
12 #if defined(BUILDING_LIBMEMCACHED)
14 #include "libmemcached/memcached.h"
16 #define MAX_UDP_DATAGRAM_LENGTH 1400
17 #define UDP_DATAGRAM_HEADER_LENGTH 8
18 #define UDP_REQUEST_ID_MSG_SIG_DIGITS 10
19 #define UDP_REQUEST_ID_THREAD_MASK 0xFFFF << UDP_REQUEST_ID_MSG_SIG_DIGITS
20 #define get_udp_datagram_request_id(A) ntohs((A)->request_id)
21 #define get_udp_datagram_seq_num(A) ntohs((A)->sequence_number)
22 #define get_udp_datagram_num_datagrams(A) ntohs((A)->num_datagrams)
23 #define get_msg_num_from_request_id(A) ( (A) & (~(UDP_REQUEST_ID_THREAD_MASK)) )
24 #define get_thread_id_from_request_id(A) ( (A) & (UDP_REQUEST_ID_THREAD_MASK) ) >> UDP_REQUEST_ID_MSG_SIG_DIGITS
25 #define generate_udp_request_thread_id(A) (A) << UDP_REQUEST_ID_MSG_SIG_DIGITS
26 #define UDP_REQUEST_ID_MAX_THREAD_ID get_thread_id_from_request_id(0xFFFF)
28 struct udp_datagram_header_st
{
30 uint16_t sequence_number
;
31 uint16_t num_datagrams
;
35 ssize_t
memcached_io_write(memcached_server_st
*ptr
,
36 const void *buffer
, size_t length
, char with_flush
);
37 void memcached_io_reset(memcached_server_st
*ptr
);
38 memcached_return
memcached_io_read(memcached_server_st
*ptr
,
39 void *buffer
, size_t length
, ssize_t
*nread
);
40 /* Read a line (terminated by '\n') into the buffer */
41 memcached_return
memcached_io_readline(memcached_server_st
*ptr
,
44 memcached_return
memcached_io_close(memcached_server_st
*ptr
);
45 /* Read n bytes of data from the server and store them in dta */
46 memcached_return
memcached_safe_read(memcached_server_st
*ptr
,
49 /* Read a single response from the server */
50 memcached_return
memcached_read_one_response(memcached_server_st
*ptr
,
51 char *buffer
, size_t buffer_length
,
52 memcached_result_st
*result
);
53 memcached_return
memcached_io_init_udp_header(memcached_server_st
*ptr
,
56 memcached_server_st
*memcached_io_get_readable_server(memcached_st
*memc
);
58 #endif /* BUILDING_LIBMEMCACHED */
59 #endif /* LIBMEMCACHED_MEMCACHED_IO_H */