-added seperate io handles for read and write
[oweals/gnunet.git] / src / include / gnunet_stream_lib.h
index af0b8e5cd8aea0484c7b55da39c96e5a4e830195..930cc1d3d587021c07b0c8fbec6470151d84f561 100644 (file)
@@ -105,6 +105,7 @@ enum GNUNET_STREAM_Option
 /**
  * Tries to open a stream to the target peer
  *
+ * @param cfg configuration to use
  * @param target the target peer to which the stream has to be opened
  * @param app_port the application port number which uniquely identifies this
  *            stream
@@ -115,7 +116,8 @@ enum GNUNET_STREAM_Option
  *         opened 
  */
 struct GNUNET_STREAM_Socket *
-GNUNET_STREAM_open (const struct GNUNET_PeerIdentity *target,
+GNUNET_STREAM_open (const struct GNUNET_CONFIGURATION_Handle *cfg,
+                    const struct GNUNET_PeerIdentity *target,
                     GNUNET_MESH_ApplicationType app_port,
                     GNUNET_STREAM_OpenCallback open_cb,
                    void *open_cb_cls,
@@ -166,6 +168,7 @@ struct GNUNET_STREAM_ListenSocket;
 /**
  * Listens for stream connections for a specific application ports
  *
+ * @param cfg the configuration to use
  * @param app_port the application port for which new streams will be accepted
  * @param listen_cb this function will be called when a peer tries to establish
  *            a stream with us
@@ -173,7 +176,8 @@ struct GNUNET_STREAM_ListenSocket;
  * @return listen socket, NULL for any error
  */
 struct GNUNET_STREAM_ListenSocket *
-GNUNET_STREAM_listen (GNUNET_MESH_ApplicationType app_port,
+GNUNET_STREAM_listen (const struct GNUNET_CONFIGURATION_Handle *cfg,
+                      GNUNET_MESH_ApplicationType app_port,
                       GNUNET_STREAM_ListenCallback listen_cb,
                       void *listen_cb_cls);
 
@@ -191,9 +195,9 @@ GNUNET_STREAM_listen_close (struct GNUNET_STREAM_ListenSocket *socket);
  * Functions of this signature are called whenever writing operations
  * on a stream are executed
  *
- * @param cls the closure from GNUNET_STREAM_write/read
+ * @param cls the closure from GNUNET_STREAM_write
  * @param status the status of the stream at the time this function is called
- * @param size the number of bytes read or written
+ * @param size the number of bytes written
  */
 typedef void (*GNUNET_STREAM_CompletionContinuation) (void *cls,
                                                      enum GNUNET_STREAM_Status
@@ -202,11 +206,16 @@ typedef void (*GNUNET_STREAM_CompletionContinuation) (void *cls,
 
 
 /**
- * Handle to cancel IO operations.
+ * Handle to cancel IO write operations.
  */
-struct GNUNET_STREAM_IOHandle;
+struct GNUNET_STREAM_IOWriteHandle;
 
 
+/**
+ * Handle to cancel IO read operations.
+ */
+struct GNUNET_STREAM_IOReadHandle;
+
 /**
  * Tries to write the given data to the stream
  *
@@ -216,9 +225,9 @@ struct GNUNET_STREAM_IOHandle;
  * @param timeout the timeout period
  * @param write_cont the function to call upon writing some bytes into the stream
  * @param write_cont_cls the closure
- * @return handle to cancel the operation
+ * @return handle to cancel the operation; NULL if a previous write is pending
  */
-struct GNUNET_STREAM_IOHandle *
+struct GNUNET_STREAM_IOWriteHandle *
 GNUNET_STREAM_write (struct GNUNET_STREAM_Socket *socket,
                      const void *data,
                      size_t size,
@@ -231,7 +240,7 @@ GNUNET_STREAM_write (struct GNUNET_STREAM_Socket *socket,
  * Functions of this signature are called whenever data is available from the
  * stream.
  *
- * @param cls the closure from GNUNET_STREAM_write/read
+ * @param cls the closure from GNUNET_STREAM_read
  * @param status the status of the stream at the time this function is called
  * @param data traffic from the other side
  * @param size the number of bytes available in data read 
@@ -253,20 +262,29 @@ typedef size_t (*GNUNET_STREAM_DataProcessor) (void *cls,
  * @param proc_cls the closure for proc
  * @return handle to cancel the operation
  */
-struct GNUNET_STREAM_IOHandle *
-GNUNET_STREAM_read (const struct GNUNET_STREAM_Socket *socket,
+struct GNUNET_STREAM_IOReadHandle *
+GNUNET_STREAM_read (struct GNUNET_STREAM_Socket *socket,
                     struct GNUNET_TIME_Relative timeout,
                    GNUNET_STREAM_DataProcessor proc,
                    void *proc_cls);
 
 
 /**
- * Cancel pending read or write operation.
+ * Cancel pending write operation.
+ *
+ * @param ioh handle to operation to cancel
+ */
+void
+GNUNET_STREAM_io_write_cancel (struct GNUNET_STREAM_IOWriteHandle *ioh);
+
+
+/**
+ * Cancel pending read operation.
  *
  * @param ioh handle to operation to cancel
  */
 void
-GNUNET_STREAM_io_cancel (struct GNUNET_STREAM_IOHandle *ioh);
+GNUNET_STREAM_io_read_cancel (struct GNUNET_STREAM_IOReadHandle *ioh);
 
 
 #if 0