rabbitmq-c  0.8.0
C AMQP Client library for RabbitMQ
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
amqp_socket.h
1 /* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */
2 /*
3  * Portions created by Alan Antonuk are Copyright (c) 2013-2014 Alan Antonuk.
4  * All Rights Reserved.
5  *
6  * Portions created by Michael Steinert are Copyright (c) 2012-2013 Michael
7  * Steinert. All Rights Reserved.
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included in
17  * all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25  * DEALINGS IN THE SOFTWARE.
26  */
27 
32 #ifndef AMQP_SOCKET_H
33 #define AMQP_SOCKET_H
34 
35 #include "amqp_private.h"
36 #include "amqp_time.h"
37 
38 AMQP_BEGIN_DECLS
39 
40 typedef enum {
41  AMQP_SF_NONE = 0,
42  AMQP_SF_MORE = 1,
43  AMQP_SF_POLLIN = 2,
44  AMQP_SF_POLLOUT = 4,
45  AMQP_SF_POLLERR = 8
46 } amqp_socket_flag_enum;
47 
48 typedef enum {
49  AMQP_SC_NONE = 0,
50  AMQP_SC_FORCE = 1
51 } amqp_socket_close_enum;
52 
53 int
54 amqp_os_socket_error(void);
55 
56 int
57 amqp_os_socket_close(int sockfd);
58 
59 /* Socket callbacks. */
60 typedef ssize_t (*amqp_socket_send_fn)(void *, const void *, size_t, int);
61 typedef ssize_t (*amqp_socket_recv_fn)(void *, void *, size_t, int);
62 typedef int (*amqp_socket_open_fn)(void *, const char *, int, struct timeval *);
63 typedef int (*amqp_socket_close_fn)(void *, amqp_socket_close_enum);
64 typedef int (*amqp_socket_get_sockfd_fn)(void *);
65 typedef void (*amqp_socket_delete_fn)(void *);
66 
69  amqp_socket_send_fn send;
70  amqp_socket_recv_fn recv;
71  amqp_socket_open_fn open;
72  amqp_socket_close_fn close;
73  amqp_socket_get_sockfd_fn get_sockfd;
74  amqp_socket_delete_fn delete;
75 };
76 
79  const struct amqp_socket_class_t *klass;
80 };
81 
82 
92 void
93 amqp_set_socket(amqp_connection_state_t state, amqp_socket_t *socket);
94 
95 
111 ssize_t
112 amqp_socket_send(amqp_socket_t *self, const void *buf, size_t len, int flags);
113 
114 ssize_t amqp_try_send(amqp_connection_state_t state, const void *buf,
115  size_t len, amqp_time_t deadline, int flags);
116 
129 ssize_t
130 amqp_socket_recv(amqp_socket_t *self, void *buf, size_t len, int flags);
131 
145 int
146 amqp_socket_close(amqp_socket_t *self, amqp_socket_close_enum force);
147 
153 void
154 amqp_socket_delete(amqp_socket_t *self);
155 
170 int
171 amqp_open_socket_noblock(char const *hostname, int portnumber, struct timeval *timeout);
172 
173 int amqp_open_socket_inner(char const *hostname, int portnumber,
174  amqp_time_t deadline);
175 
176 /* Wait up to dealline for fd to become readable or writeable depending on
177  * event (AMQP_SF_POLLIN, AMQP_SF_POLLOUT) */
178 int amqp_poll(int fd, int event, amqp_time_t deadline);
179 
180 int amqp_send_method_inner(amqp_connection_state_t state,
182  void *decoded, int flags);
183 int
184 amqp_queue_frame(amqp_connection_state_t state, amqp_frame_t *frame);
185 
186 int
187 amqp_put_back_frame(amqp_connection_state_t state, amqp_frame_t *frame);
188 
189 int
190 amqp_simple_wait_frame_on_channel(amqp_connection_state_t state,
191  amqp_channel_t channel,
192  amqp_frame_t *decoded_frame);
193 
194 int
195 sasl_mechanism_in_list(amqp_bytes_t mechanisms, amqp_sasl_method_enum method);
196 
197 int amqp_merge_capabilities(const amqp_table_t *base, const amqp_table_t *add,
198  amqp_table_t *result, amqp_pool_t *pool);
199 AMQP_END_DECLS
200 
201 #endif /* AMQP_SOCKET_H */
uint16_t amqp_channel_t
Channel type.
Definition: amqp.h:389
V-table for amqp_socket_t.
Definition: amqp_socket.h:68
AMQP field table.
Definition: amqp.h:423
An AMQP frame.
Definition: amqp.h:590
uint32_t amqp_method_number_t
Method number.
Definition: amqp.h:375
Abstract base class for amqp_socket_t.
Definition: amqp_socket.h:78
amqp_sasl_method_enum
SASL method type.
Definition: amqp.h:654
Buffer descriptor.
Definition: amqp.h:396
A memory pool.
Definition: amqp.h:559
struct amqp_connection_state_t_ * amqp_connection_state_t
connection state object
Definition: amqp.h:665
Definition: amqp_time.h:57