⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gnet-tcp.html

📁 GNet是一个简单的网络库。它是目标定向的
💻 HTML
📖 第 1 页 / 共 4 页
字号:
></DIV><HR><DIVCLASS="REFSECT2"><ANAME="AEN1349"></A><H3><ANAME="GNET-TCP-SOCKET-REF"></A>gnet_tcp_socket_ref ()</H3><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING">void        gnet_tcp_socket_ref             (<AHREF="gnet-tcp.html#GTCPSOCKET">GTcpSocket</A> *s);</PRE></TD></TR></TABLE><P>Increment the reference counter of the GTcpSocket.</P><P></P><P></P><TABLECLASS="VARIABLELIST"BORDER="0"CELLSPACING="0"CELLPADDING="4"WIDTH="100%"BGCOLOR="#FFD0D0"><TBODY><TR><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="20%"><ANAME="AEN1357"><SPANSTYLE="white-space: nowrap"><TTCLASS="PARAMETER"><I>s</I></TT>&nbsp;:</SPAN></TD><TDALIGN="LEFT"VALIGN="TOP"WIDTH="80%"><P>&#13;</P></TD></TR></TBODY></TABLE></DIV><HR><DIVCLASS="REFSECT2"><ANAME="AEN1362"></A><H3><ANAME="GNET-TCP-SOCKET-UNREF"></A>gnet_tcp_socket_unref ()</H3><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING">void        gnet_tcp_socket_unref           (<AHREF="gnet-tcp.html#GTCPSOCKET">GTcpSocket</A> *s);</PRE></TD></TR></TABLE><P>Remove a reference from the <AHREF="gnet-tcp.html#GTCPSOCKET">GTcpSocket</A>.  When reference count reaches 0, the socket is deleted.</P><P></P><P></P><TABLECLASS="VARIABLELIST"BORDER="0"CELLSPACING="0"CELLPADDING="4"WIDTH="100%"BGCOLOR="#FFD0D0"><TBODY><TR><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="20%"><ANAME="AEN1371"><SPANSTYLE="white-space: nowrap"><TTCLASS="PARAMETER"><I>s</I></TT>&nbsp;:</SPAN></TD><TDALIGN="LEFT"VALIGN="TOP"WIDTH="80%"><P>&#13;</P></TD></TR></TBODY></TABLE></DIV><HR><DIVCLASS="REFSECT2"><ANAME="AEN1376"></A><H3><ANAME="GNET-TCP-SOCKET-GET-IOCHANNEL"></A>gnet_tcp_socket_get_iochannel ()</H3><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING"><GTKDOCLINKHREF="GIOCHANNEL">GIOChannel</GTKDOCLINK>* gnet_tcp_socket_get_iochannel   (<AHREF="gnet-tcp.html#GTCPSOCKET">GTcpSocket</A> *socket);</PRE></TD></TR></TABLE><P>Get the <GTKDOCLINKHREF="GIOCHANNEL">GIOChannel</GTKDOCLINK> for the <AHREF="gnet-tcp.html#GTCPSOCKET">GTcpSocket</A>.</P><P> For a client socket, the <GTKDOCLINKHREF="GIOCHANNEL">GIOChannel</GTKDOCLINK> represents the data stream. Use it like you would any other <GTKDOCLINKHREF="GIOCHANNEL">GIOChannel</GTKDOCLINK>.</P><P> For a server socket however, the <GTKDOCLINKHREF="GIOCHANNEL">GIOChannel</GTKDOCLINK> represents incoming connections.  If you can read from it, there's a connection waiting.</P><P> There is one channel for every socket.  This function refs the channel before returning it.  You should unref the channel when you are done with it.  However, you should not close the channel - this is done when you delete the socket.</P><P></P><P></P><TABLECLASS="VARIABLELIST"BORDER="0"CELLSPACING="0"CELLPADDING="4"WIDTH="100%"BGCOLOR="#FFD0D0"><TBODY><TR><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="20%"><ANAME="AEN1393"><SPANSTYLE="white-space: nowrap"><TTCLASS="PARAMETER"><I>socket</I></TT>&nbsp;:</SPAN></TD><TDALIGN="LEFT"VALIGN="TOP"WIDTH="80%"><P></P></TD></TR><TR><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="20%"><ANAME="AEN1398"><SPANSTYLE="white-space: nowrap"><SPANCLASS="emphasis"><ICLASS="EMPHASIS">Returns</I></SPAN> :</SPAN></TD><TDALIGN="LEFT"VALIGN="TOP"WIDTH="80%"><P>&#13;</P></TD></TR></TBODY></TABLE></DIV><HR><DIVCLASS="REFSECT2"><ANAME="AEN1403"></A><H3><ANAME="GNET-TCP-SOCKET-GET-INETADDR"></A>gnet_tcp_socket_get_inetaddr ()</H3><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING"><AHREF="gnet-inetaddr.html#GINETADDR">GInetAddr</A>*  gnet_tcp_socket_get_inetaddr    (const <AHREF="gnet-tcp.html#GTCPSOCKET">GTcpSocket</A> *socket);</PRE></TD></TR></TABLE><P>Get the address of the socket.  If the socket is client socket, the address is the address of the remote host it is connected to. If the socket is a server socket, the address is the address of the local host.  (Though you should use <AHREF="gnet-inetaddr.html#GNET-INETADDR-GETHOSTADDR">gnet_inetaddr_gethostaddr</A>() to get the <AHREF="gnet-inetaddr.html#GINETADDR">GInetAddr</A> of the local host.)</P><P></P><P></P><TABLECLASS="VARIABLELIST"BORDER="0"CELLSPACING="0"CELLPADDING="4"WIDTH="100%"BGCOLOR="#FFD0D0"><TBODY><TR><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="20%"><ANAME="AEN1414"><SPANSTYLE="white-space: nowrap"><TTCLASS="PARAMETER"><I>socket</I></TT>&nbsp;:</SPAN></TD><TDALIGN="LEFT"VALIGN="TOP"WIDTH="80%"><P></P></TD></TR><TR><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="20%"><ANAME="AEN1419"><SPANSTYLE="white-space: nowrap"><SPANCLASS="emphasis"><ICLASS="EMPHASIS">Returns</I></SPAN> :</SPAN></TD><TDALIGN="LEFT"VALIGN="TOP"WIDTH="80%"><P>&#13;</P></TD></TR></TBODY></TABLE></DIV><HR><DIVCLASS="REFSECT2"><ANAME="AEN1424"></A><H3><ANAME="GNET-TCP-SOCKET-GET-PORT"></A>gnet_tcp_socket_get_port ()</H3><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING"><GTKDOCLINKHREF="GINT">gint</GTKDOCLINK>        gnet_tcp_socket_get_port        (const <AHREF="gnet-tcp.html#GTCPSOCKET">GTcpSocket</A> *socket);</PRE></TD></TR></TABLE><P>Get the port number the socket is bound to.</P><P></P><P></P><TABLECLASS="VARIABLELIST"BORDER="0"CELLSPACING="0"CELLPADDING="4"WIDTH="100%"BGCOLOR="#FFD0D0"><TBODY><TR><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="20%"><ANAME="AEN1433"><SPANSTYLE="white-space: nowrap"><TTCLASS="PARAMETER"><I>socket</I></TT>&nbsp;:</SPAN></TD><TDALIGN="LEFT"VALIGN="TOP"WIDTH="80%"><P></P></TD></TR><TR><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="20%"><ANAME="AEN1438"><SPANSTYLE="white-space: nowrap"><SPANCLASS="emphasis"><ICLASS="EMPHASIS">Returns</I></SPAN> :</SPAN></TD><TDALIGN="LEFT"VALIGN="TOP"WIDTH="80%"><P>&#13;</P></TD></TR></TBODY></TABLE></DIV><HR><DIVCLASS="REFSECT2"><ANAME="AEN1443"></A><H3><ANAME="GNETTOS"></A>enum GNetTOS</H3><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING">typedef enum{  GNET_TOS_NONE,  GNET_TOS_LOWDELAY,  GNET_TOS_THROUGHPUT,  GNET_TOS_RELIABILITY,  GNET_TOS_LOWCOST} GNetTOS;</PRE></TD></TR></TABLE><P></P></DIV><HR><DIVCLASS="REFSECT2"><ANAME="AEN1448"></A><H3><ANAME="GNET-TCP-SOCKET-SET-TOS"></A>gnet_tcp_socket_set_tos ()</H3><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING">void        gnet_tcp_socket_set_tos         (<AHREF="gnet-tcp.html#GTCPSOCKET">GTcpSocket</A> *socket,                                             <AHREF="gnet-tcp.html#GNETTOS">GNetTOS</A> tos);</PRE></TD></TR></TABLE><P>Set the type-of-service of the socket.  Usually, routers don't honor this.  Some systems don't support this function.  If the operating system does not support it, the function does nothing.</P><P></P><P></P><TABLECLASS="VARIABLELIST"BORDER="0"CELLSPACING="0"CELLPADDING="4"WIDTH="100%"BGCOLOR="#FFD0D0"><TBODY><TR><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="20%"><ANAME="AEN1457"><SPANSTYLE="white-space: nowrap"><TTCLASS="PARAMETER"><I>socket</I></TT>&nbsp;:</SPAN></TD><TDALIGN="LEFT"VALIGN="TOP"WIDTH="80%"><P></P></TD></TR><TR><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="20%"><ANAME="AEN1462"><SPANSTYLE="white-space: nowrap"><TTCLASS="PARAMETER"><I>tos</I></TT>&nbsp;:</SPAN></TD><TDALIGN="LEFT"VALIGN="TOP"WIDTH="80%"><P>&#13;</P></TD></TR></TBODY></TABLE></DIV><HR><DIVCLASS="REFSECT2"><ANAME="AEN1467"></A><H3><ANAME="GNET-TCP-SOCKET-SERVER-NEW"></A>gnet_tcp_socket_server_new ()</H3><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING"><AHREF="gnet-tcp.html#GTCPSOCKET">GTcpSocket</A>* gnet_tcp_socket_server_new      (<GTKDOCLINKHREF="GINT">gint</GTKDOCLINK> port);</PRE></TD></TR></TABLE><P>Create and open a new <AHREF="gnet-tcp.html#GTCPSOCKET">GTcpSocket</A> with the specified port number. Use this sort of socket when you are a server and you know what the port number should be (or pass 0 if you don't care what the port is).  SOCKS is used if SOCKS is enabled.</P><P></P><P></P><TABLECLASS="VARIABLELIST"BORDER="0"CELLSPACING="0"CELLPADDING="4"WIDTH="100%"BGCOLOR="#FFD0D0"><TBODY><TR><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="20%"><ANAME="AEN1477"><SPANSTYLE="white-space: nowrap"><TTCLASS="PARAMETER"><I>port</I></TT>&nbsp;:</SPAN></TD><TDALIGN="LEFT"VALIGN="TOP"WIDTH="80%"><P></P></TD></TR><TR><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="20%"><ANAME="AEN1482"><SPANSTYLE="white-space: nowrap"><SPANCLASS="emphasis"><ICLASS="EMPHASIS">Returns</I></SPAN> :</SPAN></TD><TDALIGN="LEFT"VALIGN="TOP"WIDTH="80%"><P>&#13;</P></TD></TR></TBODY></TABLE></DIV><HR><DIVCLASS="REFSECT2"><ANAME="AEN1487"></A><H3><ANAME="GNET-TCP-SOCKET-SERVER-NEW-INTERFACE"></A>gnet_tcp_socket_server_new_interface ()</H3><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING"><AHREF="gnet-tcp.html#GTCPSOCKET">GTcpSocket</A>* gnet_tcp_socket_server_new_interface                                            (const <AHREF="gnet-inetaddr.html#GINETADDR">GInetAddr</A> *iface);</PRE></TD></TR></TABLE><P>Create and open a new <AHREF="gnet-tcp.html#GTCPSOCKET">GTcpSocket</A> bound to the specified interface.  Use this sort of socket when your are a server and have a specific address the server must be bound to.  If the port number of the interface address is 0, the OS will use the interface specified but choose the port itself.  If the interface address is NULL, the OS will choose both the interface and port. If the interface address was created by <AHREF="gnet-inetaddr.html#GNET-INETADDR-NEW-ANY">gnet_inetaddr_new_any</A>(), the OS will use all interfaces.  If the port number is also set, it will use that port number.  SOCKS is used if SOCKS is enabled and the interface is NULL.</P><P></P><P></P><TABLECLASS="VARIABLELIST"BORDER="0"CELLSPACING="0"CELLPADDING="4"WIDTH="100%"BGCOLOR="#FFD0D0"><TBODY><TR><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="20%"><ANAME="AEN1498"><SPANSTYLE="white-space: nowrap"><TTCLASS="PARAMETER"><I>iface</I></TT>&nbsp;:</SPAN></TD><TDALIGN="LEFT"VALIGN="TOP"WIDTH="80%"><P></P></TD></TR><TR><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="20%"><ANAME="AEN1503"><SPANSTYLE="white-space: nowrap"><SPANCLASS="emphasis"><ICLASS="EMPHASIS">Returns</I></SPAN> :</SPAN></TD><TDALIGN="LEFT"VALIGN="TOP"WIDTH="80%"><P>&#13;</P></TD></TR></TBODY></TABLE></DIV><HR><DIVCLASS="REFSECT2"><ANAME="AEN1508"></A><H3><ANAME="GNET-TCP-SOCKET-SERVER-ACCEPT"></A>gnet_tcp_socket_server_accept ()</H3><TABLEBORDER="0"BGCOLOR="#D6E8FF"WIDTH="100%"CELLPADDING="6"><TR><TD><PRECLASS="PROGRAMLISTING"><AHREF="gnet-tcp.html#GTCPSOCKET">GTcpSocket</A>* gnet_tcp_socket_server_accept   (<AHREF="gnet-tcp.html#GTCPSOCKET">GTcpSocket</A> *socket);</PRE></TD></TR></TABLE><P>Accept a connection from the socket.  The socket must have been created using <AHREF="gnet-tcp.html#GNET-TCP-SOCKET-SERVER-NEW">gnet_tcp_socket_server_new</A>().  This function will block (use <AHREF="gnet-tcp.html#GNET-TCP-SOCKET-SERVER-ACCEPT-NONBLOCK">gnet_tcp_socket_server_accept_nonblock</A>() if you don't want to block).  If the socket's <GTKDOCLINKHREF="GIOCHANNEL">GIOChannel</GTKDOCLINK> is readable, it DOES NOT mean that this function will not block.</P><P></P><P

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -