index 5980d085ab4546c7dffd5e76c988c836aa301d00..638f8626660807a33776267f8116dbe38c8449c0 100644 (file)
#include "core/object.h"
#include "core/data.h"
-
+#include "frontend/proto.h"
#include "utils/strbuf.h"
#include <sys/socket.h>
+#include <stdbool.h>
#include <stddef.h>
#ifdef __cplusplus
/*
* sdb_client_connect:
- * Connect to the client's address.
+ * Connect to the client's address using the specified username.
*
* Returns:
* - 0 on success
* - a negative value else
*/
int
-sdb_client_connect(sdb_client_t *client);
+sdb_client_connect(sdb_client_t *client, const char *username);
+
+/*
+ * sdb_client_sockfd:
+ * Return the client socket's file descriptor.
+ */
+int
+sdb_client_sockfd(sdb_client_t *client);
+
+/*
+ * sdb_client_shutdown:
+ * Shut down the client's send and/or receive operations.
+ * See shutdown(3) for details.
+ */
+int
+sdb_client_shutdown(sdb_client_t *client, int how);
/*
* sdb_client_close:
* connection.
*
* Returns:
- * - 0 on success
+ * - the number of bytes send
* - a negative value else.
*/
ssize_t
* Receive data from the connection. All data is written to the specified
* buffer. If specified, the returned status code is written to the memory
* location pointed to by 'code'. In case of an error or an incomplete
- * command, the status code is set to UINT32_MAX.
+ * command, the status code is set to UINT32_MAX. The returned data does not
+ * include the status code and message len as received from the remote side
+ * but only the data associated with the message.
*
* Returns:
* - the number of bytes read
+ * (may be zero if the message did not include any data)
* - a negative value on error
*/
ssize_t
sdb_client_recv(sdb_client_t *client,
uint32_t *code, sdb_strbuf_t *buf);
+/*
+ * sdb_client_eof:
+ * Returns true if end of file on the client connection was reached, that is,
+ * if the remote side closed the connection.
+ */
+bool
+sdb_client_eof(sdb_client_t *client);
+
#ifdef __cplusplus
} /* extern "C" */
#endif