rabbitmq-c  0.5.3
C AMQP Client library for RabbitMQ
amqp_socket.h
00001 /* vim:set ft=c ts=2 sw=2 sts=2 et cindent: */
00002 /*
00003  * Portions created by Alan Antonuk are Copyright (c) 2013-2014 Alan Antonuk.
00004  * All Rights Reserved.
00005  *
00006  * Portions created by Michael Steinert are Copyright (c) 2012-2013 Michael
00007  * Steinert. All Rights Reserved.
00008  *
00009  * Permission is hereby granted, free of charge, to any person obtaining a
00010  * copy of this software and associated documentation files (the "Software"),
00011  * to deal in the Software without restriction, including without limitation
00012  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00013  * and/or sell copies of the Software, and to permit persons to whom the
00014  * Software is furnished to do so, subject to the following conditions:
00015  *
00016  * The above copyright notice and this permission notice shall be included in
00017  * all copies or substantial portions of the Software.
00018  *
00019  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00020  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00021  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00022  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00023  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00024  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00025  * DEALINGS IN THE SOFTWARE.
00026  */
00027 
00032 #ifndef AMQP_SOCKET_H
00033 #define AMQP_SOCKET_H
00034 
00035 #include "amqp_private.h"
00036 
00037 AMQP_BEGIN_DECLS
00038 
00039 int
00040 amqp_os_socket_error(void);
00041 
00042 int
00043 amqp_os_socket_close(int sockfd);
00044 
00045 /* Socket callbacks. */
00046 typedef ssize_t (*amqp_socket_writev_fn)(void *, struct iovec *, int);
00047 typedef ssize_t (*amqp_socket_send_fn)(void *, const void *, size_t);
00048 typedef ssize_t (*amqp_socket_recv_fn)(void *, void *, size_t, int);
00049 typedef int (*amqp_socket_open_fn)(void *, const char *, int, struct timeval *);
00050 typedef int (*amqp_socket_close_fn)(void *);
00051 typedef int (*amqp_socket_get_sockfd_fn)(void *);
00052 typedef void (*amqp_socket_delete_fn)(void *);
00053 
00055 struct amqp_socket_class_t {
00056   amqp_socket_writev_fn writev;
00057   amqp_socket_send_fn send;
00058   amqp_socket_recv_fn recv;
00059   amqp_socket_open_fn open;
00060   amqp_socket_close_fn close;
00061   amqp_socket_get_sockfd_fn get_sockfd;
00062   amqp_socket_delete_fn delete;
00063 };
00064 
00066 struct amqp_socket_t_ {
00067   const struct amqp_socket_class_t *klass;
00068 };
00069 
00070 
00071 #ifdef _WIN32
00072 /* WinSock2 calls iovec WSABUF with different parameter names.
00073  * this is really a WSABUF with different names
00074  */
00075 struct iovec {
00076   u_long iov_len;
00077   char FAR *iov_base;
00078 };
00079 #endif
00080 
00081 
00091 void
00092 amqp_set_socket(amqp_connection_state_t state, amqp_socket_t *socket);
00093 
00108 ssize_t
00109 amqp_socket_writev(amqp_socket_t *self, struct iovec *iov, int iovcnt);
00110 
00125 ssize_t
00126 amqp_socket_send(amqp_socket_t *self, const void *buf, size_t len);
00127 
00140 ssize_t
00141 amqp_socket_recv(amqp_socket_t *self, void *buf, size_t len, int flags);
00142 
00154 int
00155 amqp_socket_close(amqp_socket_t *self);
00156 
00162 void
00163 amqp_socket_delete(amqp_socket_t *self);
00164 
00179 int
00180 amqp_open_socket_noblock(char const *hostname, int portnumber, struct timeval *timeout);
00181 
00182 int
00183 amqp_queue_frame(amqp_connection_state_t state, amqp_frame_t *frame);
00184 
00185 int
00186 amqp_put_back_frame(amqp_connection_state_t state, amqp_frame_t *frame);
00187 
00188 int
00189 amqp_simple_wait_frame_on_channel(amqp_connection_state_t state,
00190                                   amqp_channel_t channel,
00191                                   amqp_frame_t *decoded_frame);
00192 
00193 AMQP_END_DECLS
00194 
00195 #endif /* AMQP_SOCKET_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines