Merge branch 'topic/mm-fixes' of git://208.110.73.182/silc into silc.1.1.branch
[silc.git] / lib / silcutil / silcsocketstream.h
index e03c3255542fe5979b8d7a8f6941cde3d88afcfd..e9fd435782959fd2e3298047571d4c2c77e9e3bb 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2005 - 2006 Pekka Riikonen
+  Copyright (C) 2005 - 2007 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
@@ -71,11 +71,15 @@ typedef enum {
  *    Callback function of this type is called after the socket stream
  *    creation is completed.  If the `stream' is NULL the socket stream could
  *    not be created or the socket connection is not otherwise allowed.  The
- *    `status' will indicate the error status.  The `stream' is socket stream
- *    representing the socket connection and silc_socket_stream_* functions
- *    can be used to access the stream.  All other silc_stream_* functions
- *    can also be used to read data, send data, and otherwise handle the
- *    stream.
+ *    `status' will indicate the error status.  In case error ocurrs the
+ *    associated socket has already been destroyed.  The `stream' is socket
+ *    stream representing the socket connection and silc_socket_stream_*
+ *    functions can be used to access the stream.  All other silc_stream_*
+ *    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,
@@ -86,7 +90,7 @@ typedef void (*SilcSocketStreamCallback)(SilcSocketStreamStatus status,
  * SYNOPSIS
  *
  *    SilcAsyncOperation
- *    silc_socket_tcp_stream_create(int sock, SilcBool lookup,
+ *    silc_socket_tcp_stream_create(SilcSocket sock, SilcBool lookup,
  *                                  SilcBool require_fqdn,
  *                                  SilcSchedule schedule,
  *                                  SilcSocketStreamCallback callback,
@@ -101,7 +105,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
@@ -111,9 +115,12 @@ 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.
+ *
  ***/
 SilcAsyncOperation
-silc_socket_tcp_stream_create(int sock, SilcBool lookup,
+silc_socket_tcp_stream_create(SilcSocket sock, SilcBool lookup,
                              SilcBool require_fqdn,
                              SilcSchedule schedule,
                              SilcSocketStreamCallback callback,
@@ -123,7 +130,8 @@ silc_socket_tcp_stream_create(int sock, SilcBool lookup,
  *
  * SYNOPSIS
  *
- *    SilcStream silc_socket_udp_stream_create(int sock, SilcBool ipv6,
+ *    SilcStream silc_socket_udp_stream_create(SilcSocket sock,
+ *                                             SilcBool ipv6,
  *                                             SilcBool connected,
  *                                             SilcSchedule schedule);
  *
@@ -150,12 +158,16 @@ silc_socket_tcp_stream_create(int 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.
+ *
  ***/
-SilcStream silc_socket_udp_stream_create(int sock, SilcBool ipv6,
+SilcStream silc_socket_udp_stream_create(SilcSocket sock,
+                                        SilcBool ipv6,
                                         SilcBool connected,
                                         SilcSchedule schedule);
 
-/****f* silcutil/SilcSocketStreamAPI/silc_socket_stream_get_info
+/****f* silcutil/SilcSocketStreamAPI/silc_socket_stream_is_udp
  *
  * SYNOPSIS
  *
@@ -165,10 +177,11 @@ SilcStream silc_socket_udp_stream_create(int sock, SilcBool ipv6,
  * 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);
@@ -179,18 +192,18 @@ SilcBool silc_socket_stream_is_udp(SilcStream stream, SilcBool *connected);
  *
  *    SilcBool
  *    silc_socket_stream_get_info(SilcStream stream,
- *                                int *sock, const char **hostname,
+ *                                SilcSocket *sock, const char **hostname,
  *                                const char **ip, SilcUInt16 *port);
  *
  * DESCRIPTION
  *
- *    Returns socket stream information such as the socket number, hostname,
- *    IP address and the port of the remote socket connection.  Return FALSE
- *    if these informations are not available.
+ *    Returns socket stream information such as the socket, remote hostname,
+ *    remote IP address and the remote port of the remote socket connection.
+ *    Return FALSE if these informations are not available.
  *
  ***/
 SilcBool silc_socket_stream_get_info(SilcStream stream,
-                                    int *sock, const char **hostname,
+                                    SilcSocket *sock, const char **hostname,
                                     const char **ip, SilcUInt16 *port);
 
 /****f* silcutil/SilcSocketStreamAPI/silc_socket_stream_set_info