rabbitmq-c
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  * Copyright 2012-2013 Michael Steinert
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  */
23 
28 #ifndef AMQP_SOCKET_H
29 #define AMQP_SOCKET_H
30 
31 #include "amqp.h"
32 
33 #ifdef _WIN32
34 # include <WinSock2.h>
35 #endif
36 
37 AMQP_BEGIN_DECLS
38 
39 int
40 amqp_os_socket_error(void);
41 
42 int
43 amqp_os_socket_close(int sockfd);
44 
45 /* Socket callbacks. */
46 typedef ssize_t (*amqp_socket_writev_fn)(void *, struct iovec *, int);
47 typedef ssize_t (*amqp_socket_send_fn)(void *, const void *, size_t);
48 typedef ssize_t (*amqp_socket_recv_fn)(void *, void *, size_t, int);
49 typedef int (*amqp_socket_open_fn)(void *, const char *, int, struct timeval *);
50 typedef int (*amqp_socket_close_fn)(void *);
51 typedef int (*amqp_socket_get_sockfd_fn)(void *);
52 typedef void (*amqp_socket_delete_fn)(void *);
53 
56  amqp_socket_writev_fn writev;
57  amqp_socket_send_fn send;
58  amqp_socket_recv_fn recv;
59  amqp_socket_open_fn open;
60  amqp_socket_close_fn close;
61  amqp_socket_get_sockfd_fn get_sockfd;
62  amqp_socket_delete_fn delete;
63 };
64 
67  const struct amqp_socket_class_t *klass;
68 };
69 
70 
71 #ifdef _WIN32
72 /* WinSock2 calls iovec WSABUF with different parameter names.
73  * this is really a WSABUF with different names
74  */
75 struct iovec {
76  u_long iov_len;
77  char FAR *iov_base;
78 };
79 #endif
80 
81 
91 void
92 amqp_set_socket(amqp_connection_state_t state, amqp_socket_t *socket);
93 
108 ssize_t
109 amqp_socket_writev(amqp_socket_t *self, struct iovec *iov, int iovcnt);
110 
125 ssize_t
126 amqp_socket_send(amqp_socket_t *self, const void *buf, size_t len);
127 
140 ssize_t
141 amqp_socket_recv(amqp_socket_t *self, void *buf, size_t len, int flags);
142 
154 AMQP_PUBLIC_FUNCTION
155 int
156 AMQP_CALL
157 amqp_socket_close(amqp_socket_t *self);
158 
164 void
165 amqp_socket_delete(amqp_socket_t *self);
166 
181 int
182 amqp_open_socket_noblock(char const *hostname, int portnumber, struct timeval *timeout);
183 
184 int
185 amqp_queue_frame(amqp_connection_state_t state, amqp_frame_t *frame);
186 
187 int
188 amqp_simple_wait_frame_on_channel(amqp_connection_state_t state,
189  amqp_channel_t channel,
190  amqp_frame_t *decoded_frame);
191 
192 AMQP_END_DECLS
193 
194 #endif /* AMQP_SOCKET_H */