SILC Runtime Toolkit 1.2 Beta 1
[runtime.git] / lib / silcutil / silcsocketstream.h
index 560e7e0f8faf6b36abab88fa5171e60644c6b01f..c642796b60045d530a30f2bedb4b65dfd88f8a36 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2005 - 2006 Pekka Riikonen
+  Copyright (C) 2005 - 2008 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
 
 */
 
-/****h* silcutil/SILC Socket Stream Interface
+/****h* silcutil/Socket Stream Interface
  *
  * DESCRIPTION
  *
 #ifndef SILCSOCKETSTREAM_H
 #define SILCSOCKETSTREAM_H
 
-/****d* silcutil/SilcSocketStreamAPI/SilcSocketStreamStatus
- *
- * NAME
- *
- *    typedef enum { ... } SilcStreamStatus;
- *
- * DESCRIPTION
- *
- *    Socket Stream status.  This status is returned into the
- *    SilcSocketStreamCallback function after the socket stream is
- *    created.
- *
- * SOURCE
- */
-typedef enum {
-  SILC_SOCKET_OK,              /* Normal status */
-  SILC_SOCKET_UNKNOWN_IP,      /* Remote does not have IP address */
-  SILC_SOCKET_UNKNOWN_HOST,    /* Remote does not have host name */
-  SILC_SOCKET_NO_MEMORY,       /* System out of memory */
-  SILC_SOCKET_ERROR,           /* Unknown error */
-} SilcSocketStreamStatus;
-/***/
-
-/****f* silcutil/SilcSocketStreamAPI/SilcSocketStreamCallback
+/****f* silcutil/SilcSocketStreamCallback
  *
  * SYNOPSIS
  *
- *    typedef void (*SilcSocketStreamCallback)(SilcSocketStreamStatus status,
+ *    typedef void (*SilcSocketStreamCallback)(SilcResult status,
  *                                             SilcStream stream,
  *                                             void *context);
  *
@@ -78,11 +55,14 @@ typedef enum {
  *    functions can also be used to read data, send data, and otherwise
  *    handle the stream.
  *
+ *    If the silc_stream_set_notifier is called the stream will be set to
+ *    non-blocking mode.
+ *
  ***/
-typedef void (*SilcSocketStreamCallback)(SilcSocketStreamStatus status,
+typedef void (*SilcSocketStreamCallback)(SilcResult status,
                                         SilcStream stream, void *context);
 
-/****f* silcutil/SilcSocketStreamAPI/silc_socket_tcp_stream_create
+/****f* silcutil/silc_socket_tcp_stream_create
  *
  * SYNOPSIS
  *
@@ -102,7 +82,7 @@ typedef void (*SilcSocketStreamCallback)(SilcSocketStreamStatus status,
  *    socket connection information, such as hostname and IP address are
  *    resolved, so SilcAsyncOperation is returned which can be used to cancel
  *    the creation process.  The `callback' will be called to return the
- *    created socket stream.  To destroy the stream call silc_stream_destroy.
+ *    created socket stream.
  *
  *    If the `lookup' is TRUE then this will perform IP and hostname lookup
  *    for the socket.  If the `require_fqdn' is TRUE then the socket must
@@ -112,6 +92,10 @@ typedef void (*SilcSocketStreamCallback)(SilcSocketStreamStatus status,
  *    will not be available from the socket stream.  In that case this will
  *    also return NULL as the `callback' is called immediately.
  *
+ *    If the silc_stream_set_notifier is called the stream is set to
+ *    non-blocking mode.  If `schedule' is NULL this will call
+ *    silc_schedule_get_global to try to get global scheduler.
+ *
  ***/
 SilcAsyncOperation
 silc_socket_tcp_stream_create(SilcSocket sock, SilcBool lookup,
@@ -120,7 +104,7 @@ silc_socket_tcp_stream_create(SilcSocket sock, SilcBool lookup,
                              SilcSocketStreamCallback callback,
                              void *context);
 
-/****f* silcutil/SilcSocketStreamAPI/silc_socket_udp_stream_create
+/****f* silcutil/silc_socket_udp_stream_create
  *
  * SYNOPSIS
  *
@@ -152,13 +136,17 @@ silc_socket_tcp_stream_create(SilcSocket sock, SilcBool lookup,
  *
  *    This function returns the created SilcStream or NULL on error.
  *
+ *    If the silc_stream_set_notifier is called the stream is set to
+ *    non-blocking mode.  If `schedule' is NULL this will call
+ *    silc_schedule_get_global to try to get global scheduler.
+ *
  ***/
 SilcStream silc_socket_udp_stream_create(SilcSocket sock,
                                         SilcBool ipv6,
                                         SilcBool connected,
                                         SilcSchedule schedule);
 
-/****f* silcutil/SilcSocketStreamAPI/silc_socket_stream_get_info
+/****f* silcutil/silc_socket_stream_is_udp
  *
  * SYNOPSIS
  *
@@ -168,15 +156,16 @@ SilcStream silc_socket_udp_stream_create(SilcSocket sock,
  * DESCRIPTION
  *
  *    Returns TRUE if the `stream' is UDP stream.  If the `connected' pointer
- *    is non-NULL indication whether the UDP stream is in connected state.
- *    If it is then packets can be read and written using silc_stream_read
- *    and silc_stream_write.  If it is not then packets need to read and
- *    written by using silc_net_udp_receive and silc_net_udp_send.
+ *    is non-NULL it will have indication whether the UDP stream is in
+ *    connected state.  If it is then packets can be read and written using
+ *    silc_stream_read and silc_stream_write.  If it is not then packets
+ *    need to read and written by using silc_net_udp_receive and
+ *    silc_net_udp_send.
  *
  ***/
 SilcBool silc_socket_stream_is_udp(SilcStream stream, SilcBool *connected);
 
-/****f* silcutil/SilcSocketStreamAPI/silc_socket_stream_get_info
+/****f* silcutil/silc_socket_stream_get_info
  *
  * SYNOPSIS
  *
@@ -196,7 +185,7 @@ SilcBool silc_socket_stream_get_info(SilcStream stream,
                                     SilcSocket *sock, const char **hostname,
                                     const char **ip, SilcUInt16 *port);
 
-/****f* silcutil/SilcSocketStreamAPI/silc_socket_stream_set_info
+/****f* silcutil/silc_socket_stream_set_info
  *
  * SYNOPSIS
  *
@@ -221,21 +210,7 @@ SilcBool silc_socket_stream_set_info(SilcStream stream,
                                     const char *hostname,
                                     const char *ip, SilcUInt16 port);
 
-/****f* silcutil/SilcSocketStreamAPI/silc_socket_stream_get_error
- *
- * SYNOPSIS
- *
- *    int silc_socket_stream_get_error(SilcStream stream);
- *
- * DESCRIPTION
- *
- *    If error occurred during socket stream operations, this function
- *    can be used to retrieve the error number that occurred.
- *
- ***/
-int silc_socket_stream_get_error(SilcStream stream);
-
-/****f* silcutil/SilcSocketStreamAPI/silc_socket_stream_set_qos
+/****f* silcutil/silc_socket_stream_set_qos
  *
  * SYNOPSIS
  *
@@ -255,7 +230,7 @@ int silc_socket_stream_get_error(SilcStream stream);
  *    more than `read_limit_bytes' of data.  The `limit_sec' and `limit_usec'
  *    specifies the time limit that is applied if `read_rate' and/or
  *    `read_limit_bytes' is reached.  If all arguments except `stream'
- *    are zero this resets the QoS from the socket stream, all QoS for
+ *    are zero this resets the QoS from the socket stream, all QoS data for
  *    this socket stream that may be pending will be cancelled.
  *
  ***/