summaryrefslogtreecommitdiff
path: root/librabbitmq/amqp_socket.h
diff options
context:
space:
mode:
Diffstat (limited to 'librabbitmq/amqp_socket.h')
-rw-r--r--librabbitmq/amqp_socket.h75
1 files changed, 67 insertions, 8 deletions
diff --git a/librabbitmq/amqp_socket.h b/librabbitmq/amqp_socket.h
index 52815fe..bdeea63 100644
--- a/librabbitmq/amqp_socket.h
+++ b/librabbitmq/amqp_socket.h
@@ -28,11 +28,7 @@
#ifndef AMQP_SOCKET_H
#define AMQP_SOCKET_H
-#include "amqp.h"
-
-#ifdef _WIN32
-# include <WinSock2.h>
-#endif
+#include "amqp_private.h"
AMQP_BEGIN_DECLS
@@ -46,10 +42,10 @@ amqp_os_socket_close(int sockfd);
typedef ssize_t (*amqp_socket_writev_fn)(void *, struct iovec *, int);
typedef ssize_t (*amqp_socket_send_fn)(void *, const void *, size_t);
typedef ssize_t (*amqp_socket_recv_fn)(void *, void *, size_t, int);
-typedef int (*amqp_socket_open_fn)(void *, const char *, int);
+typedef int (*amqp_socket_open_fn)(void *, const char *, int, struct timeval *);
typedef int (*amqp_socket_close_fn)(void *);
-typedef int (*amqp_socket_error_fn)(void *);
typedef int (*amqp_socket_get_sockfd_fn)(void *);
+typedef void (*amqp_socket_delete_fn)(void *);
/** V-table for amqp_socket_t */
struct amqp_socket_class_t {
@@ -58,8 +54,8 @@ struct amqp_socket_class_t {
amqp_socket_recv_fn recv;
amqp_socket_open_fn open;
amqp_socket_close_fn close;
- amqp_socket_error_fn error;
amqp_socket_get_sockfd_fn get_sockfd;
+ amqp_socket_delete_fn delete;
};
/** Abstract base class for amqp_socket_t */
@@ -78,6 +74,19 @@ struct iovec {
};
#endif
+
+/**
+ * Set set the socket object for a connection
+ *
+ * This assigns a socket object to the connection, closing and deleting any
+ * existing socket
+ *
+ * \param [in] state The connection object to add the socket to
+ * \param [in] socket The socket object to assign to the connection
+ */
+void
+amqp_set_socket(amqp_connection_state_t state, amqp_socket_t *socket);
+
/**
* Write to a socket.
*
@@ -127,6 +136,56 @@ amqp_socket_send(amqp_socket_t *self, const void *buf, size_t len);
ssize_t
amqp_socket_recv(amqp_socket_t *self, void *buf, size_t len, int flags);
+/**
+ * Close a socket connection and free resources.
+ *
+ * This function closes a socket connection and releases any resources used by
+ * the object. After calling this function the specified socket should no
+ * longer be referenced.
+ *
+ * \param [in,out] self A socket object.
+ *
+ * \return Zero upon success, non-zero otherwise.
+ */
+int
+amqp_socket_close(amqp_socket_t *self);
+
+/**
+ * Destroy a socket object
+ *
+ * \param [in] self the socket object to delete
+ */
+void
+amqp_socket_delete(amqp_socket_t *self);
+
+/**
+ * Open a socket connection.
+ *
+ * This function opens a socket connection returned from amqp_tcp_socket_new()
+ * or amqp_ssl_socket_new(). This function should be called after setting
+ * socket options and prior to assigning the socket to an AMQP connection with
+ * amqp_set_socket().
+ *
+ * \param [in] host Connect to this host.
+ * \param [in] port Connect on this remote port.
+ * \param [in] timeout Max allowed time to spent on opening. If NULL - run in blocking mode
+ *
+ * \return File descriptor upon success, non-zero negative error code otherwise.
+ */
+int
+amqp_open_socket_noblock(char const *hostname, int portnumber, struct timeval *timeout);
+
+int
+amqp_queue_frame(amqp_connection_state_t state, amqp_frame_t *frame);
+
+int
+amqp_put_back_frame(amqp_connection_state_t state, amqp_frame_t *frame);
+
+int
+amqp_simple_wait_frame_on_channel(amqp_connection_state_t state,
+ amqp_channel_t channel,
+ amqp_frame_t *decoded_frame);
+
AMQP_END_DECLS
#endif /* AMQP_SOCKET_H */