?? conn.sgml
字號:
<!-- ##### SECTION Title ##### -->Conn<!-- ##### SECTION Short_Description ##### -->TCP connection object<!-- ##### SECTION Long_Description ##### --><para>A #GConn represents a TCP connection. A #GConn is created directly bycalling gnet_conn_new() or gnet_conn_new_inetaddr(). To connect tothe host, call gnet_conn_connect() and to disconnect callgnet_conn_disconnect(). #GConn's are also created by a #GServer whena client connects. Call gnet_conn_set_callback() to set the #GConncallback after it is created by the #GServer. To disconnect anddelete the GConn, call gnet_conn_delete().</para><para>The iochannel field and #GIOChannel functions can be used to read fromor write to the socket. #GIOChannel functions block. To make anasynchronous read call gnet_conn_read() and to make an asynchronouswrite call gnet_conn_write(). The callback is called whenever a reador write completes.</para><para>Use gnet_conn_set_watch_error() to get an event if an error occurs.Use gnet_conn_set_watch_readable() and gnet_conn_set_watch_writable()to get events when the connection is readable or writable. These canbe used to implement custom I/O handling. For example, considerwriting from a mmap()'ed file. gnet_conn_write() will allocate memoryfor a buffer and copy part of the file into the buffer. To avoid thecopy, use gnet_conn_set_watch_writable() to catch the writable eventand then write directly from memory to the socket.</para><para>gnet_conn_timeout() sets a timeout on the GConn. The%GNET_CONN_TIMEOUT event occurs when the timer expires. For example,the timer may be set before connecting to the host. If the connectionis made, the %GNET_CONN_CONNECT event occurs. The timer can then bereset by setting the timeout to 0. Otherwise, the %GNET_CONN_TIMEOUTevent will eventually occur.</para><!-- ##### SECTION See_Also ##### --><para>See also GServer and the echoclient-gconn example.</para><!-- ##### STRUCT GConn ##### --><para></para>@hostname: @port: @iochannel: @socket: @inetaddr: @ref_count: @ref_count_internal: @connect_id: @new_id: @write_queue: @bytes_written: @buffer: @length: @bytes_read: @read_eof: @read_queue: @process_buffer_timeout: @watch_readable: @watch_writable: @watch_flags: @watch: @timer: @func: @user_data: <!-- ##### STRUCT GConnEvent ##### --><para></para>@type: @buffer: @length: <!-- ##### ENUM GConnEventType ##### --><para></para>@GNET_CONN_ERROR: @GNET_CONN_CONNECT: @GNET_CONN_CLOSE: @GNET_CONN_TIMEOUT: @GNET_CONN_READ: @GNET_CONN_WRITE: @GNET_CONN_READABLE: @GNET_CONN_WRITABLE: <!-- ##### USER_FUNCTION GConnFunc ##### --><para></para>@conn: @event: @user_data: <!-- ##### FUNCTION gnet_conn_new ##### --><para></para>@hostname: @port: @func: @user_data: @Returns: <!-- ##### FUNCTION gnet_conn_new_inetaddr ##### --><para></para>@inetaddr: @func: @user_data: @Returns: <!-- ##### FUNCTION gnet_conn_new_socket ##### --><para></para>@socket: @func: @user_data: @Returns: <!-- ##### FUNCTION gnet_conn_delete ##### --><para></para>@conn: <!-- ##### FUNCTION gnet_conn_ref ##### --><para></para>@conn: <!-- ##### FUNCTION gnet_conn_unref ##### --><para></para>@conn: <!-- ##### FUNCTION gnet_conn_set_callback ##### --><para></para>@conn: @func: @user_data: <!-- ##### FUNCTION gnet_conn_connect ##### --><para></para>@conn: <!-- ##### FUNCTION gnet_conn_disconnect ##### --><para></para>@conn: <!-- ##### FUNCTION gnet_conn_is_connected ##### --><para></para>@conn: @Returns: <!-- ##### FUNCTION gnet_conn_read ##### --><para></para>@conn: <!-- ##### FUNCTION gnet_conn_readn ##### --><para></para>@conn: @length: <!-- ##### FUNCTION gnet_conn_readline ##### --><para></para>@conn: <!-- ##### FUNCTION gnet_conn_write ##### --><para></para>@conn: @buffer: @length: <!-- ##### FUNCTION gnet_conn_set_watch_error ##### --><para></para>@conn: @enable: <!-- ##### FUNCTION gnet_conn_set_watch_readable ##### --><para></para>@conn: @enable: <!-- ##### FUNCTION gnet_conn_set_watch_writable ##### --><para></para>@conn: @enable: <!-- ##### FUNCTION gnet_conn_timeout ##### --><para></para>@conn: @timeout:
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -