src/sock.h
changeset 10 9fe218576d13
parent 9 4c4c906cc649
child 12 4147fae232d9
--- a/src/sock.h	Sun Feb 22 08:48:21 2009 +0200
+++ b/src/sock.h	Sun Feb 22 10:16:28 2009 +0200
@@ -51,15 +51,26 @@
 err_t sock_gnutls_connect (struct sock_stream **sock_ptr, const char *host, const char *service, struct error_info *err);
 
 /*
- * Set the callbacks for a sock_stream. Note that the callbacks struct isn't copied - it's used as-is-given.
+ * The generic read/write API for stream sockets.
  */
-void sock_stream_set_callbacks (struct sock_stream *sock, const struct sock_stream_callbacks *callbacks, void *arg);
+int sock_stream_read (struct sock_stream *sock, void *buf, size_t len);
+int sock_stream_write (struct sock_stream *sock, const void *buf, size_t len);
 
 /*
- * The generic read/write API for stream sockets.
+ * Initialize event-based operation for this sock_stream. This will set the stream into nonblocking mode, and the given
+ * callbacks will be fired once enabled using sock_stream_event_enable().
+ *
+ * Note that the callbacks struct isn't copied - it's used as-is-given.
  */
-err_t sock_stream_read (struct sock_stream *sock, void *buf, size_t len);
-err_t sock_stream_write (struct sock_stream *sock, const void *buf, size_t len);
+err_t sock_stream_event_init (struct sock_stream *sock, const struct sock_stream_callbacks *callbacks, void *arg);
+
+/*
+ * Prime the callbacks set up earlier with sock_stream_event_init to fire once ready.
+ *
+ * \a mask is a bitmask of EV_* bits, such as EV_READ, EV_WRITE or EV_PERSIST. See event_set() for more info about the
+ * behaviour of those.
+ */
+err_t sock_stream_event_enable (struct sock_stream *sock, short mask);
 
 /**
  * Get current error_info for \a sock.