]> git.cworth.org Git - ttt/blobdiff - src/ttt-socket.h
2005-12-04 Bryan Worth <bryan@theworths.org>
[ttt] / src / ttt-socket.h
index 909501e0e37880c0f44d178d12e5d71b069b058d..e3cd9bca8a515bf328121f03aeee5f213044e177 100644 (file)
@@ -55,4 +55,42 @@ ttt_socket_accept (int                                listen_socket,
                   ttt_socket_accept_func_t      accept,
                   void                         *closure);
 
+/* Create a socket, and connect it to the given host and port,
+ * returing it in socket_ret.
+ *
+ * Lookup for host (e.g. /etc/hosts and DNS) and port (e.g /etc/services)
+ * will be performed if necessary.
+ *
+ * Return value: TTT_STATUS_SUCCESS if successful.
+ *              TTT_STATUS_CONNECTION_REFUSED: no server listening.
+ *              TTT_STATUS_NETWORK_UNREACHABLE: <obvious meaning>
+ *
+ * Errors: If any error other than those listed above occurs, this
+ * function will not return.
+ */
+ttt_status_t
+ttt_socket_create_client (const char   *host,
+                         const char    *port,
+                         int           *socket_ret);
+
+/* Perform a blocking read, until all count bytes are read from the
+ * socket to buf, which must be of size count or larger.
+ *
+ * Errors: If any errors occur, this function does not return.
+ */
+ssize_t
+ttt_socket_read (int    socket,
+                void   *buf,
+                size_t  count);
+
+/* Perform a blocking write, until all count bytes are written from
+ * buf to the socket.
+ *
+ * Errors: If any errors occur, this function does not return.
+ */
+void
+ttt_socket_write (int           socket,
+                 const void    *buf,
+                 size_t         count);
+
 #endif