| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| <html> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <title>GSocket</title> |
| <meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> |
| <link rel="home" href="index.html" title="GIO Reference Manual"> |
| <link rel="up" href="networking.html" title="Lowlevel platform-independent network support"> |
| <link rel="prev" href="networking.html" title="Lowlevel platform-independent network support"> |
| <link rel="next" href="GInetAddress.html" title="GInetAddress"> |
| <meta name="generator" content="GTK-Doc V1.14 (XML mode)"> |
| <link rel="stylesheet" href="style.css" type="text/css"> |
| </head> |
| <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
| <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"> |
| <tr valign="middle"> |
| <td><a accesskey="p" href="networking.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td> |
| <td><a accesskey="u" href="networking.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td> |
| <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td> |
| <th width="100%" align="center">GIO Reference Manual</th> |
| <td><a accesskey="n" href="GInetAddress.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td> |
| </tr> |
| <tr><td colspan="5" class="shortcuts"> |
| <a href="#GSocket.synopsis" class="shortcut">Top</a> |
| | |
| <a href="#GSocket.description" class="shortcut">Description</a> |
| | |
| <a href="#GSocket.object-hierarchy" class="shortcut">Object Hierarchy</a> |
| | |
| <a href="#GSocket.implemented-interfaces" class="shortcut">Implemented Interfaces</a> |
| | |
| <a href="#GSocket.properties" class="shortcut">Properties</a> |
| </td></tr> |
| </table> |
| <div class="refentry" title="GSocket"> |
| <a name="GSocket"></a><div class="titlepage"></div> |
| <div class="refnamediv"><table width="100%"><tr> |
| <td valign="top"> |
| <h2><span class="refentrytitle"><a name="GSocket.top_of_page"></a>GSocket</span></h2> |
| <p>GSocket — Low-level socket object</p> |
| </td> |
| <td valign="top" align="right"></td> |
| </tr></table></div> |
| <div class="refsynopsisdiv" title="Synopsis"> |
| <a name="GSocket.synopsis"></a><h2>Synopsis</h2> |
| <pre class="synopsis"> |
| #include <gio/gio.h> |
| |
| <a class="link" href="GSocket.html#GSocket-struct" title="GSocket">GSocket</a>; |
| <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> (<a class="link" href="GSocket.html#GSocketSourceFunc" title="GSocketSourceFunc ()">*GSocketSourceFunc</a>) (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#GIOCondition"><span class="type">GIOCondition</span></a> condition</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> user_data</code></em>); |
| enum <a class="link" href="GSocket.html#GSocketType" title="enum GSocketType">GSocketType</a>; |
| enum <a class="link" href="GSocket.html#GSocketProtocol" title="enum GSocketProtocol">GSocketProtocol</a>; |
| enum <a class="link" href="GSocket.html#GSocketMsgFlags" title="enum GSocketMsgFlags">GSocketMsgFlags</a>; |
| <a class="link" href="GSocket.html#GInputVector" title="GInputVector">GInputVector</a>; |
| <a class="link" href="GSocket.html#GOutputVector" title="GOutputVector">GOutputVector</a>; |
| <a class="link" href="GSocket.html" title="GSocket"><span class="returnvalue">GSocket</span></a> * <a class="link" href="GSocket.html#g-socket-new" title="g_socket_new ()">g_socket_new</a> (<em class="parameter"><code><a class="link" href="GSocketAddress.html#GSocketFamily" title="enum GSocketFamily"><span class="type">GSocketFamily</span></a> family</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocket.html#GSocketType" title="enum GSocketType"><span class="type">GSocketType</span></a> type</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocket.html#GSocketProtocol" title="enum GSocketProtocol"><span class="type">GSocketProtocol</span></a> protocol</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>); |
| <a class="link" href="GSocket.html" title="GSocket"><span class="returnvalue">GSocket</span></a> * <a class="link" href="GSocket.html#g-socket-new-from-fd" title="g_socket_new_from_fd ()">g_socket_new_from_fd</a> (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> fd</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>); |
| <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="GSocket.html#g-socket-bind" title="g_socket_bind ()">g_socket_bind</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *address</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> allow_reuse</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>); |
| <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="GSocket.html#g-socket-listen" title="g_socket_listen ()">g_socket_listen</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>); |
| <a class="link" href="GSocket.html" title="GSocket"><span class="returnvalue">GSocket</span></a> * <a class="link" href="GSocket.html#g-socket-accept" title="g_socket_accept ()">g_socket_accept</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>); |
| <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="GSocket.html#g-socket-connect" title="g_socket_connect ()">g_socket_connect</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *address</code></em>, |
| <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>); |
| <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="GSocket.html#g-socket-check-connect-result" title="g_socket_check_connect_result ()">g_socket_check_connect_result</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>); |
| <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> <a class="link" href="GSocket.html#g-socket-receive" title="g_socket_receive ()">g_socket_receive</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *buffer</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> size</code></em>, |
| <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>); |
| <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> <a class="link" href="GSocket.html#g-socket-receive-from" title="g_socket_receive_from ()">g_socket_receive_from</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> **address</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *buffer</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> size</code></em>, |
| <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>); |
| <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> <a class="link" href="GSocket.html#g-socket-receive-message" title="g_socket_receive_message ()">g_socket_receive_message</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> **address</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocket.html#GInputVector" title="GInputVector"><span class="type">GInputVector</span></a> *vectors</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> num_vectors</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocketControlMessage.html" title="GSocketControlMessage"><span class="type">GSocketControlMessage</span></a> ***messages</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> *num_messages</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> *flags</code></em>, |
| <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>); |
| <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> <a class="link" href="GSocket.html#g-socket-send" title="g_socket_send ()">g_socket_send</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *buffer</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> size</code></em>, |
| <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>); |
| <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> <a class="link" href="GSocket.html#g-socket-send-to" title="g_socket_send_to ()">g_socket_send_to</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *address</code></em>, |
| <em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *buffer</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> size</code></em>, |
| <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>); |
| <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> <a class="link" href="GSocket.html#g-socket-send-message" title="g_socket_send_message ()">g_socket_send_message</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *address</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocket.html#GOutputVector" title="GOutputVector"><span class="type">GOutputVector</span></a> *vectors</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> num_vectors</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocketControlMessage.html" title="GSocketControlMessage"><span class="type">GSocketControlMessage</span></a> **messages</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> num_messages</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> flags</code></em>, |
| <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>); |
| <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="GSocket.html#g-socket-close" title="g_socket_close ()">g_socket_close</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>); |
| <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="GSocket.html#g-socket-is-closed" title="g_socket_is_closed ()">g_socket_is_closed</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>); |
| <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="GSocket.html#g-socket-shutdown" title="g_socket_shutdown ()">g_socket_shutdown</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> shutdown_read</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> shutdown_write</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>); |
| <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="GSocket.html#g-socket-is-connected" title="g_socket_is_connected ()">g_socket_is_connected</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>); |
| <a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSource"><span class="returnvalue">GSource</span></a> * <a class="link" href="GSocket.html#g-socket-create-source" title="g_socket_create_source ()">g_socket_create_source</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#GIOCondition"><span class="type">GIOCondition</span></a> condition</code></em>, |
| <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>); |
| <a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#GIOCondition"><span class="returnvalue">GIOCondition</span></a> <a class="link" href="GSocket.html#g-socket-condition-check" title="g_socket_condition_check ()">g_socket_condition_check</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#GIOCondition"><span class="type">GIOCondition</span></a> condition</code></em>); |
| <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="GSocket.html#g-socket-condition-wait" title="g_socket_condition_wait ()">g_socket_condition_wait</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#GIOCondition"><span class="type">GIOCondition</span></a> condition</code></em>, |
| <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>); |
| <span class="returnvalue">void</span> <a class="link" href="GSocket.html#g-socket-set-listen-backlog" title="g_socket_set_listen_backlog ()">g_socket_set_listen_backlog</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> backlog</code></em>); |
| <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a> <a class="link" href="GSocket.html#g-socket-get-listen-backlog" title="g_socket_get_listen_backlog ()">g_socket_get_listen_backlog</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>); |
| <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="GSocket.html#g-socket-get-blocking" title="g_socket_get_blocking ()">g_socket_get_blocking</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>); |
| <span class="returnvalue">void</span> <a class="link" href="GSocket.html#g-socket-set-blocking" title="g_socket_set_blocking ()">g_socket_set_blocking</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> blocking</code></em>); |
| <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="GSocket.html#g-socket-get-keepalive" title="g_socket_get_keepalive ()">g_socket_get_keepalive</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>); |
| <span class="returnvalue">void</span> <a class="link" href="GSocket.html#g-socket-set-keepalive" title="g_socket_set_keepalive ()">g_socket_set_keepalive</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> keepalive</code></em>); |
| <a class="link" href="GSocketAddress.html#GSocketFamily" title="enum GSocketFamily"><span class="returnvalue">GSocketFamily</span></a> <a class="link" href="GSocket.html#g-socket-get-family" title="g_socket_get_family ()">g_socket_get_family</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>); |
| <span class="returnvalue">int</span> <a class="link" href="GSocket.html#g-socket-get-fd" title="g_socket_get_fd ()">g_socket_get_fd</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>); |
| <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="returnvalue">GSocketAddress</span></a> * <a class="link" href="GSocket.html#g-socket-get-local-address" title="g_socket_get_local_address ()">g_socket_get_local_address</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>); |
| <a class="link" href="GSocket.html#GSocketProtocol" title="enum GSocketProtocol"><span class="returnvalue">GSocketProtocol</span></a> <a class="link" href="GSocket.html#g-socket-get-protocol" title="g_socket_get_protocol ()">g_socket_get_protocol</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>); |
| <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="returnvalue">GSocketAddress</span></a> * <a class="link" href="GSocket.html#g-socket-get-remote-address" title="g_socket_get_remote_address ()">g_socket_get_remote_address</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>); |
| <a class="link" href="GSocket.html#GSocketType" title="enum GSocketType"><span class="returnvalue">GSocketType</span></a> <a class="link" href="GSocket.html#g-socket-get-socket-type" title="g_socket_get_socket_type ()">g_socket_get_socket_type</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>); |
| <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="GSocket.html#g-socket-speaks-ipv4" title="g_socket_speaks_ipv4 ()">g_socket_speaks_ipv4</a> (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>); |
| </pre> |
| </div> |
| <div class="refsect1" title="Object Hierarchy"> |
| <a name="GSocket.object-hierarchy"></a><h2>Object Hierarchy</h2> |
| <pre class="synopsis"> |
| <a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject">GObject</a> |
| +----GSocket |
| </pre> |
| </div> |
| <div class="refsect1" title="Implemented Interfaces"> |
| <a name="GSocket.implemented-interfaces"></a><h2>Implemented Interfaces</h2> |
| <p> |
| GSocket implements |
| <a class="link" href="GInitable.html" title="GInitable">GInitable</a>.</p> |
| </div> |
| <div class="refsect1" title="Properties"> |
| <a name="GSocket.properties"></a><h2>Properties</h2> |
| <pre class="synopsis"> |
| "<a class="link" href="GSocket.html#GSocket--blocking" title='The "blocking" property'>blocking</a>" <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> : Read / Write |
| "<a class="link" href="GSocket.html#GSocket--family" title='The "family" property'>family</a>" <a class="link" href="GSocketAddress.html#GSocketFamily" title="enum GSocketFamily"><span class="type">GSocketFamily</span></a> : Read / Write / Construct Only |
| "<a class="link" href="GSocket.html#GSocket--fd" title='The "fd" property'>fd</a>" <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> : Read / Write / Construct Only |
| "<a class="link" href="GSocket.html#GSocket--keepalive" title='The "keepalive" property'>keepalive</a>" <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> : Read / Write |
| "<a class="link" href="GSocket.html#GSocket--listen-backlog" title='The "listen-backlog" property'>listen-backlog</a>" <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> : Read / Write |
| "<a class="link" href="GSocket.html#GSocket--local-address" title='The "local-address" property'>local-address</a>" <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a>* : Read |
| "<a class="link" href="GSocket.html#GSocket--protocol" title='The "protocol" property'>protocol</a>" <a class="link" href="GSocket.html#GSocketProtocol" title="enum GSocketProtocol"><span class="type">GSocketProtocol</span></a> : Read / Write / Construct Only |
| "<a class="link" href="GSocket.html#GSocket--remote-address" title='The "remote-address" property'>remote-address</a>" <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a>* : Read |
| "<a class="link" href="GSocket.html#GSocket--type" title='The "type" property'>type</a>" <a class="link" href="GSocket.html#GSocketType" title="enum GSocketType"><span class="type">GSocketType</span></a> : Read / Write / Construct Only |
| </pre> |
| </div> |
| <div class="refsect1" title="Description"> |
| <a name="GSocket.description"></a><h2>Description</h2> |
| <p> |
| A <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> is a low-level networking primitive. It is a more or less |
| direct mapping of the BSD socket API in a portable GObject based API. |
| It supports both the UNIX socket implementations and winsock2 on Windows. |
| </p> |
| <p> |
| <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> is the platform independent base upon which the higher level |
| network primitives are based. Applications are not typically meant to |
| use it directly, but rather through classes like <a class="link" href="GSocketClient.html" title="GSocketClient"><span class="type">GSocketClient</span></a>, |
| <a class="link" href="GSocketService.html" title="GSocketService"><span class="type">GSocketService</span></a> and <a class="link" href="GSocketConnection.html" title="GSocketConnection"><span class="type">GSocketConnection</span></a>. However there may be cases where |
| direct use of <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> is useful. |
| </p> |
| <p> |
| <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> implements the <a class="link" href="GInitable.html" title="GInitable"><span class="type">GInitable</span></a> interface, so if it is manually constructed |
| by e.g. <a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#g-object-new"><code class="function">g_object_new()</code></a> you must call <a class="link" href="GInitable.html#g-initable-init" title="g_initable_init ()"><code class="function">g_initable_init()</code></a> and check the |
| results before using the object. This is done automatically in |
| <a class="link" href="GSocket.html#g-socket-new" title="g_socket_new ()"><code class="function">g_socket_new()</code></a> and <a class="link" href="GSocket.html#g-socket-new-from-fd" title="g_socket_new_from_fd ()"><code class="function">g_socket_new_from_fd()</code></a>, so these functions can return |
| <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. |
| </p> |
| <p> |
| Sockets operate in two general modes, blocking or non-blocking. When |
| in blocking mode all operations block until the requested operation |
| is finished or there is an error. In non-blocking mode all calls that |
| would block return immediately with a <a class="link" href="gio-GIOError.html#G-IO-ERROR-WOULD-BLOCK:CAPS"><code class="literal">G_IO_ERROR_WOULD_BLOCK</code></a> error. |
| To know when a call would successfully run you can call <a class="link" href="GSocket.html#g-socket-condition-check" title="g_socket_condition_check ()"><code class="function">g_socket_condition_check()</code></a>, |
| or <a class="link" href="GSocket.html#g-socket-condition-wait" title="g_socket_condition_wait ()"><code class="function">g_socket_condition_wait()</code></a>. You can also use <a class="link" href="GSocket.html#g-socket-create-source" title="g_socket_create_source ()"><code class="function">g_socket_create_source()</code></a> and |
| attach it to a <a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GMainContext"><span class="type">GMainContext</span></a> to get callbacks when I/O is possible. |
| Note that all sockets are always set to non blocking mode in the system, and |
| blocking mode is emulated in GSocket. |
| </p> |
| <p> |
| When working in non-blocking mode applications should always be able to |
| handle getting a <a class="link" href="gio-GIOError.html#G-IO-ERROR-WOULD-BLOCK:CAPS"><code class="literal">G_IO_ERROR_WOULD_BLOCK</code></a> error even when some other |
| function said that I/O was possible. This can easily happen in case |
| of a race condition in the application, but it can also happen for other |
| reasons. For instance, on Windows a socket is always seen as writable |
| until a write returns <a class="link" href="gio-GIOError.html#G-IO-ERROR-WOULD-BLOCK:CAPS"><code class="literal">G_IO_ERROR_WOULD_BLOCK</code></a>. |
| </p> |
| <p> |
| <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>s can be either connection oriented or datagram based. |
| For connection oriented types you must first establish a connection by |
| either connecting to an address or accepting a connection from another |
| address. For connectionless socket types the target/source address is |
| specified or received in each I/O operation. |
| </p> |
| <p> |
| All socket file descriptors are set to be close-on-exec. |
| </p> |
| <p> |
| Note that creating a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> causes the signal <code class="literal">SIGPIPE</code> to be |
| ignored for the remainder of the program. If you are writing a |
| command-line utility that uses <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>, you may need to take into |
| account the fact that your program will not automatically be killed |
| if it tries to write to <code class="literal">stdout</code> after it has been closed. |
| </p> |
| </div> |
| <div class="refsect1" title="Details"> |
| <a name="GSocket.details"></a><h2>Details</h2> |
| <div class="refsect2" title="GSocket"> |
| <a name="GSocket-struct"></a><h3>GSocket</h3> |
| <pre class="programlisting">typedef struct _GSocket GSocket;</pre> |
| <p> |
| A lowlevel network socket object. |
| </p> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="GSocketSourceFunc ()"> |
| <a name="GSocketSourceFunc"></a><h3>GSocketSourceFunc ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> (*GSocketSourceFunc) (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#GIOCondition"><span class="type">GIOCondition</span></a> condition</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre> |
| <p> |
| This is the function type of the callback used for the <a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSource"><span class="type">GSource</span></a> |
| returned by <a class="link" href="GSocket.html#g-socket-create-source" title="g_socket_create_source ()"><code class="function">g_socket_create_source()</code></a>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>the <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>condition</code></em> :</span></p></td> |
| <td>the current condition at the source fired. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td> |
| <td>data passed in by the user. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> it should return <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> if the source should be removed. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="enum GSocketType"> |
| <a name="GSocketType"></a><h3>enum GSocketType</h3> |
| <pre class="programlisting">typedef enum |
| { |
| G_SOCKET_TYPE_INVALID, |
| G_SOCKET_TYPE_STREAM, |
| G_SOCKET_TYPE_DATAGRAM, |
| G_SOCKET_TYPE_SEQPACKET |
| } GSocketType; |
| </pre> |
| <p> |
| Flags used when creating a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>. Some protocols may not implement |
| all the socket types. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><a name="G-SOCKET-TYPE-INVALID:CAPS"></a><span class="term"><code class="literal">G_SOCKET_TYPE_INVALID</code></span></p></td> |
| <td>Type unknown or wrong |
| </td> |
| </tr> |
| <tr> |
| <td><p><a name="G-SOCKET-TYPE-STREAM:CAPS"></a><span class="term"><code class="literal">G_SOCKET_TYPE_STREAM</code></span></p></td> |
| <td>Reliable connection-based byte streams (e.g. TCP). |
| </td> |
| </tr> |
| <tr> |
| <td><p><a name="G-SOCKET-TYPE-DATAGRAM:CAPS"></a><span class="term"><code class="literal">G_SOCKET_TYPE_DATAGRAM</code></span></p></td> |
| <td>Connectionless, unreliable datagram passing. |
| (e.g. UDP) |
| </td> |
| </tr> |
| <tr> |
| <td><p><a name="G-SOCKET-TYPE-SEQPACKET:CAPS"></a><span class="term"><code class="literal">G_SOCKET_TYPE_SEQPACKET</code></span></p></td> |
| <td>Reliable connection-based passing of datagrams |
| of fixed maximum length (e.g. SCTP). |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="enum GSocketProtocol"> |
| <a name="GSocketProtocol"></a><h3>enum GSocketProtocol</h3> |
| <pre class="programlisting">typedef enum { |
| G_SOCKET_PROTOCOL_UNKNOWN = -1, |
| G_SOCKET_PROTOCOL_DEFAULT = 0, |
| G_SOCKET_PROTOCOL_TCP = 6, |
| G_SOCKET_PROTOCOL_UDP = 17, |
| G_SOCKET_PROTOCOL_SCTP = 132 |
| } GSocketProtocol; |
| </pre> |
| <p> |
| A protocol identifier is specified when creating a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>, which is a |
| family/type specific identifier, where 0 means the default protocol for |
| the particular family/type. |
| </p> |
| <p> |
| This enum contains a set of commonly available and used protocols. You |
| can also pass any other identifiers handled by the platform in order to |
| use protocols not listed here. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><a name="G-SOCKET-PROTOCOL-UNKNOWN:CAPS"></a><span class="term"><code class="literal">G_SOCKET_PROTOCOL_UNKNOWN</code></span></p></td> |
| <td>The protocol type is unknown |
| </td> |
| </tr> |
| <tr> |
| <td><p><a name="G-SOCKET-PROTOCOL-DEFAULT:CAPS"></a><span class="term"><code class="literal">G_SOCKET_PROTOCOL_DEFAULT</code></span></p></td> |
| <td>The default protocol for the family/type |
| </td> |
| </tr> |
| <tr> |
| <td><p><a name="G-SOCKET-PROTOCOL-TCP:CAPS"></a><span class="term"><code class="literal">G_SOCKET_PROTOCOL_TCP</code></span></p></td> |
| <td>TCP over IP |
| </td> |
| </tr> |
| <tr> |
| <td><p><a name="G-SOCKET-PROTOCOL-UDP:CAPS"></a><span class="term"><code class="literal">G_SOCKET_PROTOCOL_UDP</code></span></p></td> |
| <td>UDP over IP |
| </td> |
| </tr> |
| <tr> |
| <td><p><a name="G-SOCKET-PROTOCOL-SCTP:CAPS"></a><span class="term"><code class="literal">G_SOCKET_PROTOCOL_SCTP</code></span></p></td> |
| <td>SCTP over IP |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="enum GSocketMsgFlags"> |
| <a name="GSocketMsgFlags"></a><h3>enum GSocketMsgFlags</h3> |
| <pre class="programlisting">typedef enum |
| { |
| G_SOCKET_MSG_NONE, |
| G_SOCKET_MSG_OOB = GLIB_SYSDEF_MSG_OOB, |
| G_SOCKET_MSG_PEEK = GLIB_SYSDEF_MSG_PEEK, |
| G_SOCKET_MSG_DONTROUTE = GLIB_SYSDEF_MSG_DONTROUTE |
| } GSocketMsgFlags; |
| </pre> |
| <p> |
| Flags used in <a class="link" href="GSocket.html#g-socket-receive-message" title="g_socket_receive_message ()"><code class="function">g_socket_receive_message()</code></a> and <a class="link" href="GSocket.html#g-socket-send-message" title="g_socket_send_message ()"><code class="function">g_socket_send_message()</code></a>. |
| The flags listed in the enum are some commonly available flags, but the |
| values used for them are the same as on the platform, and any other flags |
| are passed in/out as is. So to use a platform specific flag, just include |
| the right system header and pass in the flag. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><a name="G-SOCKET-MSG-NONE:CAPS"></a><span class="term"><code class="literal">G_SOCKET_MSG_NONE</code></span></p></td> |
| <td>No flags. |
| </td> |
| </tr> |
| <tr> |
| <td><p><a name="G-SOCKET-MSG-OOB:CAPS"></a><span class="term"><code class="literal">G_SOCKET_MSG_OOB</code></span></p></td> |
| <td>Request to send/receive out of band data. |
| </td> |
| </tr> |
| <tr> |
| <td><p><a name="G-SOCKET-MSG-PEEK:CAPS"></a><span class="term"><code class="literal">G_SOCKET_MSG_PEEK</code></span></p></td> |
| <td>Read data from the socket without removing it from |
| the queue. |
| </td> |
| </tr> |
| <tr> |
| <td><p><a name="G-SOCKET-MSG-DONTROUTE:CAPS"></a><span class="term"><code class="literal">G_SOCKET_MSG_DONTROUTE</code></span></p></td> |
| <td>Don't use a gateway to send out the packet, |
| only send to hosts on directly connected networks. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="GInputVector"> |
| <a name="GInputVector"></a><h3>GInputVector</h3> |
| <pre class="programlisting">typedef struct { |
| gpointer buffer; |
| gsize size; |
| } GInputVector; |
| </pre> |
| <p> |
| Structure used for scatter/gather data input. |
| You generally pass in an array of <a class="link" href="GSocket.html#GInputVector" title="GInputVector"><span class="type">GInputVector</span></a>s |
| and the operation will store the read data starting in the |
| first buffer, switching to the next as needed. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> <em class="structfield"><code><a name="GInputVector.buffer"></a>buffer</code></em>;</span></p></td> |
| <td>Pointer to a buffer where data will be written. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> <em class="structfield"><code><a name="GInputVector.size"></a>size</code></em>;</span></p></td> |
| <td>the available size in <em class="parameter"><code>buffer</code></em>. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="GOutputVector"> |
| <a name="GOutputVector"></a><h3>GOutputVector</h3> |
| <pre class="programlisting">typedef struct { |
| gconstpointer buffer; |
| gsize size; |
| } GOutputVector; |
| </pre> |
| <p> |
| Structure used for scatter/gather data output. |
| You generally pass in an array of <a class="link" href="GSocket.html#GOutputVector" title="GOutputVector"><span class="type">GOutputVector</span></a>s |
| and the operation will use all the buffers as if they were |
| one buffer. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gconstpointer"><span class="type">gconstpointer</span></a> <em class="structfield"><code><a name="GOutputVector.buffer"></a>buffer</code></em>;</span></p></td> |
| <td>Pointer to a buffer of data to read. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> <em class="structfield"><code><a name="GOutputVector.size"></a>size</code></em>;</span></p></td> |
| <td>the size of <em class="parameter"><code>buffer</code></em>. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_new ()"> |
| <a name="g-socket-new"></a><h3>g_socket_new ()</h3> |
| <pre class="programlisting"><a class="link" href="GSocket.html" title="GSocket"><span class="returnvalue">GSocket</span></a> * g_socket_new (<em class="parameter"><code><a class="link" href="GSocketAddress.html#GSocketFamily" title="enum GSocketFamily"><span class="type">GSocketFamily</span></a> family</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocket.html#GSocketType" title="enum GSocketType"><span class="type">GSocketType</span></a> type</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocket.html#GSocketProtocol" title="enum GSocketProtocol"><span class="type">GSocketProtocol</span></a> protocol</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p> |
| Creates a new <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> with the defined family, type and protocol. |
| If <em class="parameter"><code>protocol</code></em> is 0 (<a class="link" href="GSocket.html#G-SOCKET-PROTOCOL-DEFAULT:CAPS"><code class="literal">G_SOCKET_PROTOCOL_DEFAULT</code></a>) the default protocol type |
| for the family and type is used. |
| </p> |
| <p> |
| The <em class="parameter"><code>protocol</code></em> is a family and type specific int that specifies what |
| kind of protocol to use. <a class="link" href="GSocket.html#GSocketProtocol" title="enum GSocketProtocol"><span class="type">GSocketProtocol</span></a> lists several common ones. |
| Many families only support one protocol, and use 0 for this, others |
| support several and using 0 means to use the default protocol for |
| the family and type. |
| </p> |
| <p> |
| The protocol id is passed directly to the operating |
| system, so you can use protocols not listed in <a class="link" href="GSocket.html#GSocketProtocol" title="enum GSocketProtocol"><span class="type">GSocketProtocol</span></a> if you |
| know the protocol number used for it. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>family</code></em> :</span></p></td> |
| <td>the socket family to use, e.g. <a class="link" href="GSocketAddress.html#G-SOCKET-FAMILY-IPV4:CAPS"><code class="literal">G_SOCKET_FAMILY_IPV4</code></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>type</code></em> :</span></p></td> |
| <td>the socket type to use. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>protocol</code></em> :</span></p></td> |
| <td>the id of the protocol to use, or 0 for default. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td> |
| <td> |
| <a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on error. |
| Free the returned object with <a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a>. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_new_from_fd ()"> |
| <a name="g-socket-new-from-fd"></a><h3>g_socket_new_from_fd ()</h3> |
| <pre class="programlisting"><a class="link" href="GSocket.html" title="GSocket"><span class="returnvalue">GSocket</span></a> * g_socket_new_from_fd (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> fd</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p> |
| Creates a new <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> from a native file descriptor |
| or winsock SOCKET handle. |
| </p> |
| <p> |
| This reads all the settings from the file descriptor so that |
| all properties should work. Note that the file descriptor |
| will be set to non-blocking mode, independent on the blocking |
| mode of the <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>fd</code></em> :</span></p></td> |
| <td>a native socket file descriptor. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td> |
| <td> |
| <a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on error. |
| Free the returned object with <a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a>. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_bind ()"> |
| <a name="g-socket-bind"></a><h3>g_socket_bind ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_socket_bind (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *address</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> allow_reuse</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p> |
| When a socket is created it is attached to an address family, but it |
| doesn't have an address in this family. <a class="link" href="GSocket.html#g-socket-bind" title="g_socket_bind ()"><code class="function">g_socket_bind()</code></a> assigns the |
| address (sometimes called name) of the socket. |
| </p> |
| <p> |
| It is generally required to bind to a local address before you can |
| receive connections. (See <a class="link" href="GSocket.html#g-socket-listen" title="g_socket_listen ()"><code class="function">g_socket_listen()</code></a> and <a class="link" href="GSocket.html#g-socket-accept" title="g_socket_accept ()"><code class="function">g_socket_accept()</code></a> ). |
| In certain situations, you may also want to bind a socket that will be |
| used to initiate connections, though this is not normally required. |
| </p> |
| <p> |
| <em class="parameter"><code>allow_reuse</code></em> should be <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> for server sockets (sockets that you will |
| eventually call <a class="link" href="GSocket.html#g-socket-accept" title="g_socket_accept ()"><code class="function">g_socket_accept()</code></a> on), and <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> for client sockets. |
| (Specifically, if it is <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>, then <a class="link" href="GSocket.html#g-socket-bind" title="g_socket_bind ()"><code class="function">g_socket_bind()</code></a> will set the |
| <code class="literal">SO_REUSEADDR</code> flag on the socket, allowing it to bind <em class="parameter"><code>address</code></em> even if |
| that address was previously used by another socket that has not yet been |
| fully cleaned-up by the kernel. Failing to set this flag on a server |
| socket may cause the bind call to return <a class="link" href="gio-GIOError.html#G-IO-ERROR-ADDRESS-IN-USE:CAPS"><code class="literal">G_IO_ERROR_ADDRESS_IN_USE</code></a> if |
| the server program is stopped and then immediately restarted.) |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>address</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> specifying the local address. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>allow_reuse</code></em> :</span></p></td> |
| <td>whether to allow reusing this address |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td> |
| <td> |
| <a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> on error. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_listen ()"> |
| <a name="g-socket-listen"></a><h3>g_socket_listen ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_socket_listen (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p> |
| Marks the socket as a server socket, i.e. a socket that is used |
| to accept incoming requests using <a class="link" href="GSocket.html#g-socket-accept" title="g_socket_accept ()"><code class="function">g_socket_accept()</code></a>. |
| </p> |
| <p> |
| Before calling this the socket must be bound to a local address using |
| <a class="link" href="GSocket.html#g-socket-bind" title="g_socket_bind ()"><code class="function">g_socket_bind()</code></a>. |
| </p> |
| <p> |
| To set the maximum amount of outstanding clients, use |
| <a class="link" href="GSocket.html#g-socket-set-listen-backlog" title="g_socket_set_listen_backlog ()"><code class="function">g_socket_set_listen_backlog()</code></a>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td> |
| <td> |
| <a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> on error. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_accept ()"> |
| <a name="g-socket-accept"></a><h3>g_socket_accept ()</h3> |
| <pre class="programlisting"><a class="link" href="GSocket.html" title="GSocket"><span class="returnvalue">GSocket</span></a> * g_socket_accept (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p> |
| Accept incoming connections on a connection-based socket. This removes |
| the first outstanding connection request from the listening socket and |
| creates a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> object for it. |
| </p> |
| <p> |
| The <em class="parameter"><code>socket</code></em> must be bound to a local address with <a class="link" href="GSocket.html#g-socket-bind" title="g_socket_bind ()"><code class="function">g_socket_bind()</code></a> and |
| must be listening for incoming connections (<a class="link" href="GSocket.html#g-socket-listen" title="g_socket_listen ()"><code class="function">g_socket_listen()</code></a>). |
| </p> |
| <p> |
| If there are no outstanding connections then the operation will block |
| or return <a class="link" href="gio-GIOError.html#G-IO-ERROR-WOULD-BLOCK:CAPS"><code class="literal">G_IO_ERROR_WOULD_BLOCK</code></a> if non-blocking I/O is enabled. |
| To be notified of an incoming connection, wait for the <a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#G-IO-IN:CAPS"><code class="literal">G_IO_IN</code></a> condition. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td> |
| <td>a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td> |
| <td> |
| <a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> a new <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on error. |
| Free the returned object with <a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a>. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_connect ()"> |
| <a name="g-socket-connect"></a><h3>g_socket_connect ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_socket_connect (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *address</code></em>, |
| <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p> |
| Connect the socket to the specified remote address. |
| </p> |
| <p> |
| For connection oriented socket this generally means we attempt to make |
| a connection to the <em class="parameter"><code>address</code></em>. For a connection-less socket it sets |
| the default address for <a class="link" href="GSocket.html#g-socket-send" title="g_socket_send ()"><code class="function">g_socket_send()</code></a> and discards all incoming datagrams |
| from other sources. |
| </p> |
| <p> |
| Generally connection oriented sockets can only connect once, but |
| connection-less sockets can connect multiple times to change the |
| default address. |
| </p> |
| <p> |
| If the connect call needs to do network I/O it will block, unless |
| non-blocking I/O is enabled. Then <a class="link" href="gio-GIOError.html#G-IO-ERROR-PENDING:CAPS"><code class="literal">G_IO_ERROR_PENDING</code></a> is returned |
| and the user can be notified of the connection finishing by waiting |
| for the G_IO_OUT condition. The result of the connection can then be |
| checked with <a class="link" href="GSocket.html#g-socket-check-connect-result" title="g_socket_check_connect_result ()"><code class="function">g_socket_check_connect_result()</code></a>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>address</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> specifying the remote address. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td> |
| <td>a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td> |
| <td> |
| <a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if connected, <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> on error. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_check_connect_result ()"> |
| <a name="g-socket-check-connect-result"></a><h3>g_socket_check_connect_result ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_socket_check_connect_result (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p> |
| Checks and resets the pending connect error for the socket. |
| This is used to check for errors when <a class="link" href="GSocket.html#g-socket-connect" title="g_socket_connect ()"><code class="function">g_socket_connect()</code></a> is |
| used in non-blocking mode. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td> |
| <td> |
| <a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if no error, <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise, setting <em class="parameter"><code>error</code></em> to the error |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_receive ()"> |
| <a name="g-socket-receive"></a><h3>g_socket_receive ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> g_socket_receive (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *buffer</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> size</code></em>, |
| <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p> |
| Receive data (up to <em class="parameter"><code>size</code></em> bytes) from a socket. This is mainly used by |
| connection-oriented sockets; it is identical to <a class="link" href="GSocket.html#g-socket-receive-from" title="g_socket_receive_from ()"><code class="function">g_socket_receive_from()</code></a> |
| with <em class="parameter"><code>address</code></em> set to <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. |
| </p> |
| <p> |
| For <a class="link" href="GSocket.html#G-SOCKET-TYPE-DATAGRAM:CAPS"><code class="literal">G_SOCKET_TYPE_DATAGRAM</code></a> and <a class="link" href="GSocket.html#G-SOCKET-TYPE-SEQPACKET:CAPS"><code class="literal">G_SOCKET_TYPE_SEQPACKET</code></a> sockets, |
| <a class="link" href="GSocket.html#g-socket-receive" title="g_socket_receive ()"><code class="function">g_socket_receive()</code></a> will always read either 0 or 1 complete messages from |
| the socket. If the received message is too large to fit in <em class="parameter"><code>buffer</code></em>, then |
| the data beyond <em class="parameter"><code>size</code></em> bytes will be discarded, without any explicit |
| indication that this has occurred. |
| </p> |
| <p> |
| For <a class="link" href="GSocket.html#G-SOCKET-TYPE-STREAM:CAPS"><code class="literal">G_SOCKET_TYPE_STREAM</code></a> sockets, <a class="link" href="GSocket.html#g-socket-receive" title="g_socket_receive ()"><code class="function">g_socket_receive()</code></a> can return any |
| number of bytes, up to <em class="parameter"><code>size</code></em>. If more than <em class="parameter"><code>size</code></em> bytes have been |
| received, the additional data will be returned in future calls to |
| <a class="link" href="GSocket.html#g-socket-receive" title="g_socket_receive ()"><code class="function">g_socket_receive()</code></a>. |
| </p> |
| <p> |
| If the socket is in blocking mode the call will block until there is |
| some data to receive or there is an error. If there is no data available |
| and the socket is in non-blocking mode, a <a class="link" href="gio-GIOError.html#G-IO-ERROR-WOULD-BLOCK:CAPS"><code class="literal">G_IO_ERROR_WOULD_BLOCK</code></a> error |
| will be returned. To be notified when data is available, wait for the |
| <a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#G-IO-IN:CAPS"><code class="literal">G_IO_IN</code></a> condition. |
| </p> |
| <p> |
| On error -1 is returned and <em class="parameter"><code>error</code></em> is set accordingly. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>buffer</code></em> :</span></p></td> |
| <td>a buffer to read data into (which should be at least <em class="parameter"><code>size</code></em> |
| bytes long). |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>size</code></em> :</span></p></td> |
| <td>the number of bytes you want to read from the socket |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td> |
| <td>a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td> |
| <td> |
| <a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> Number of bytes read, or -1 on error |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_receive_from ()"> |
| <a name="g-socket-receive-from"></a><h3>g_socket_receive_from ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> g_socket_receive_from (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> **address</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *buffer</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> size</code></em>, |
| <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p> |
| Receive data (up to <em class="parameter"><code>size</code></em> bytes) from a socket. |
| </p> |
| <p> |
| If <em class="parameter"><code>address</code></em> is non-<a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> then <em class="parameter"><code>address</code></em> will be set equal to the |
| source address of the received packet. |
| <em class="parameter"><code>address</code></em> is owned by the caller. |
| </p> |
| <p> |
| See <a class="link" href="GSocket.html#g-socket-receive" title="g_socket_receive ()"><code class="function">g_socket_receive()</code></a> for additional information. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>address</code></em> :</span></p></td> |
| <td>a pointer to a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> pointer, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>buffer</code></em> :</span></p></td> |
| <td>a buffer to read data into (which should be at least <em class="parameter"><code>size</code></em> |
| bytes long). |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>size</code></em> :</span></p></td> |
| <td>the number of bytes you want to read from the socket |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td> |
| <td>a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td> |
| <td> |
| <a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> Number of bytes read, or -1 on error |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_receive_message ()"> |
| <a name="g-socket-receive-message"></a><h3>g_socket_receive_message ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> g_socket_receive_message (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> **address</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocket.html#GInputVector" title="GInputVector"><span class="type">GInputVector</span></a> *vectors</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> num_vectors</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocketControlMessage.html" title="GSocketControlMessage"><span class="type">GSocketControlMessage</span></a> ***messages</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> *num_messages</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> *flags</code></em>, |
| <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p> |
| Receive data from a socket. This is the most complicated and |
| fully-featured version of this call. For easier use, see |
| <a class="link" href="GSocket.html#g-socket-receive" title="g_socket_receive ()"><code class="function">g_socket_receive()</code></a> and <a class="link" href="GSocket.html#g-socket-receive-from" title="g_socket_receive_from ()"><code class="function">g_socket_receive_from()</code></a>. |
| </p> |
| <p> |
| If <em class="parameter"><code>address</code></em> is non-<a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> then <em class="parameter"><code>address</code></em> will be set equal to the |
| source address of the received packet. |
| <em class="parameter"><code>address</code></em> is owned by the caller. |
| </p> |
| <p> |
| <em class="parameter"><code>vector</code></em> must point to an array of <a class="link" href="GSocket.html#GInputVector" title="GInputVector"><span class="type">GInputVector</span></a> structs and |
| <em class="parameter"><code>num_vectors</code></em> must be the length of this array. These structs |
| describe the buffers that received data will be scattered into. |
| If <em class="parameter"><code>num_vectors</code></em> is -1, then <em class="parameter"><code>vectors</code></em> is assumed to be terminated |
| by a <a class="link" href="GSocket.html#GInputVector" title="GInputVector"><span class="type">GInputVector</span></a> with a <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> buffer pointer. |
| </p> |
| <p> |
| As a special case, if <em class="parameter"><code>num_vectors</code></em> is 0 (in which case, <em class="parameter"><code>vectors</code></em> |
| may of course be <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>), then a single byte is received and |
| discarded. This is to facilitate the common practice of sending a |
| single '\0' byte for the purposes of transferring ancillary data. |
| </p> |
| <p> |
| <em class="parameter"><code>messages</code></em>, if non-<a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, will be set to point to a newly-allocated |
| array of <a class="link" href="GSocketControlMessage.html" title="GSocketControlMessage"><span class="type">GSocketControlMessage</span></a> instances. These correspond to the |
| control messages received from the kernel, one |
| <a class="link" href="GSocketControlMessage.html" title="GSocketControlMessage"><span class="type">GSocketControlMessage</span></a> per message from the kernel. This array is |
| <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>-terminated and must be freed by the caller using <a href="/usr/share/gtk-doc/html/glib/glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a>. If |
| <em class="parameter"><code>messages</code></em> is <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, any control messages received will be |
| discarded. |
| </p> |
| <p> |
| <em class="parameter"><code>num_messages</code></em>, if non-<a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, will be set to the number of control |
| messages received. |
| </p> |
| <p> |
| If both <em class="parameter"><code>messages</code></em> and <em class="parameter"><code>num_messages</code></em> are non-<a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, then |
| <em class="parameter"><code>num_messages</code></em> gives the number of <a class="link" href="GSocketControlMessage.html" title="GSocketControlMessage"><span class="type">GSocketControlMessage</span></a> instances |
| in <em class="parameter"><code>messages</code></em> (ie: not including the <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> terminator). |
| </p> |
| <p> |
| <em class="parameter"><code>flags</code></em> is an in/out parameter. The commonly available arguments |
| for this are available in the <a class="link" href="GSocket.html#GSocketMsgFlags" title="enum GSocketMsgFlags"><span class="type">GSocketMsgFlags</span></a> enum, but the |
| values there are the same as the system values, and the flags |
| are passed in as-is, so you can pass in system-specific flags too |
| (and <a class="link" href="GSocket.html#g-socket-receive-message" title="g_socket_receive_message ()"><code class="function">g_socket_receive_message()</code></a> may pass system-specific flags out). |
| </p> |
| <p> |
| As with <a class="link" href="GSocket.html#g-socket-receive" title="g_socket_receive ()"><code class="function">g_socket_receive()</code></a>, data may be discarded if <em class="parameter"><code>socket</code></em> is |
| <a class="link" href="GSocket.html#G-SOCKET-TYPE-DATAGRAM:CAPS"><code class="literal">G_SOCKET_TYPE_DATAGRAM</code></a> or <a class="link" href="GSocket.html#G-SOCKET-TYPE-SEQPACKET:CAPS"><code class="literal">G_SOCKET_TYPE_SEQPACKET</code></a> and you do not |
| provide enough buffer space to read a complete message. You can pass |
| <a class="link" href="GSocket.html#G-SOCKET-MSG-PEEK:CAPS"><code class="literal">G_SOCKET_MSG_PEEK</code></a> in <em class="parameter"><code>flags</code></em> to peek at the current message without |
| removing it from the receive queue, but there is no portable way to find |
| out the length of the message other than by reading it into a |
| sufficiently-large buffer. |
| </p> |
| <p> |
| If the socket is in blocking mode the call will block until there |
| is some data to receive or there is an error. If there is no data |
| available and the socket is in non-blocking mode, a |
| <a class="link" href="gio-GIOError.html#G-IO-ERROR-WOULD-BLOCK:CAPS"><code class="literal">G_IO_ERROR_WOULD_BLOCK</code></a> error will be returned. To be notified when |
| data is available, wait for the <a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#G-IO-IN:CAPS"><code class="literal">G_IO_IN</code></a> condition. |
| </p> |
| <p> |
| On error -1 is returned and <em class="parameter"><code>error</code></em> is set accordingly. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>address</code></em> :</span></p></td> |
| <td>a pointer to a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> pointer, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>vectors</code></em> :</span></p></td> |
| <td>an array of <a class="link" href="GSocket.html#GInputVector" title="GInputVector"><span class="type">GInputVector</span></a> structs |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>num_vectors</code></em> :</span></p></td> |
| <td>the number of elements in <em class="parameter"><code>vectors</code></em>, or -1 |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>messages</code></em> :</span></p></td> |
| <td>a pointer which will be filled with an array of |
| <a href="GSocketControlMessage.html"><span class="type">GSocketControlMessages</span></a>, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>num_messages</code></em> :</span></p></td> |
| <td>a pointer which will be filled with the number of |
| elements in <em class="parameter"><code>messages</code></em>, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>flags</code></em> :</span></p></td> |
| <td>a pointer to an int containing <a class="link" href="GSocket.html#GSocketMsgFlags" title="enum GSocketMsgFlags"><span class="type">GSocketMsgFlags</span></a> flags |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td> |
| <td>a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td> |
| <td>a <a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> pointer, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> Number of bytes read, or -1 on error |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_send ()"> |
| <a name="g-socket-send"></a><h3>g_socket_send ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> g_socket_send (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *buffer</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> size</code></em>, |
| <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p> |
| Tries to send <em class="parameter"><code>size</code></em> bytes from <em class="parameter"><code>buffer</code></em> on the socket. This is |
| mainly used by connection-oriented sockets; it is identical to |
| <a class="link" href="GSocket.html#g-socket-send-to" title="g_socket_send_to ()"><code class="function">g_socket_send_to()</code></a> with <em class="parameter"><code>address</code></em> set to <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. |
| </p> |
| <p> |
| If the socket is in blocking mode the call will block until there is |
| space for the data in the socket queue. If there is no space available |
| and the socket is in non-blocking mode a <a class="link" href="gio-GIOError.html#G-IO-ERROR-WOULD-BLOCK:CAPS"><code class="literal">G_IO_ERROR_WOULD_BLOCK</code></a> error |
| will be returned. To be notified when space is available, wait for the |
| <a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#G-IO-OUT:CAPS"><code class="literal">G_IO_OUT</code></a> condition. Note though that you may still receive |
| <a class="link" href="gio-GIOError.html#G-IO-ERROR-WOULD-BLOCK:CAPS"><code class="literal">G_IO_ERROR_WOULD_BLOCK</code></a> from <a class="link" href="GSocket.html#g-socket-send" title="g_socket_send ()"><code class="function">g_socket_send()</code></a> even if you were previously |
| notified of a <a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#G-IO-OUT:CAPS"><code class="literal">G_IO_OUT</code></a> condition. (On Windows in particular, this is |
| very common due to the way the underlying APIs work.) |
| </p> |
| <p> |
| On error -1 is returned and <em class="parameter"><code>error</code></em> is set accordingly. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>buffer</code></em> :</span></p></td> |
| <td>the buffer containing the data to send. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>size</code></em> :</span></p></td> |
| <td>the number of bytes to send |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td> |
| <td>a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td> |
| <td> |
| <a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> Number of bytes written (which may be less than <em class="parameter"><code>size</code></em>), or -1 |
| on error |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_send_to ()"> |
| <a name="g-socket-send-to"></a><h3>g_socket_send_to ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> g_socket_send_to (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *address</code></em>, |
| <em class="parameter"><code>const <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *buffer</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> size</code></em>, |
| <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p> |
| Tries to send <em class="parameter"><code>size</code></em> bytes from <em class="parameter"><code>buffer</code></em> to <em class="parameter"><code>address</code></em>. If <em class="parameter"><code>address</code></em> is |
| <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> then the message is sent to the default receiver (set by |
| <a class="link" href="GSocket.html#g-socket-connect" title="g_socket_connect ()"><code class="function">g_socket_connect()</code></a>). |
| </p> |
| <p> |
| See <a class="link" href="GSocket.html#g-socket-send" title="g_socket_send ()"><code class="function">g_socket_send()</code></a> for additional information. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>address</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a>, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>buffer</code></em> :</span></p></td> |
| <td>the buffer containing the data to send. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>size</code></em> :</span></p></td> |
| <td>the number of bytes to send |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td> |
| <td>a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td> |
| <td> |
| <a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> Number of bytes written (which may be less than <em class="parameter"><code>size</code></em>), or -1 |
| on error |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_send_message ()"> |
| <a name="g-socket-send-message"></a><h3>g_socket_send_message ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> g_socket_send_message (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *address</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocket.html#GOutputVector" title="GOutputVector"><span class="type">GOutputVector</span></a> *vectors</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> num_vectors</code></em>, |
| <em class="parameter"><code><a class="link" href="GSocketControlMessage.html" title="GSocketControlMessage"><span class="type">GSocketControlMessage</span></a> **messages</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> num_messages</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> flags</code></em>, |
| <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p> |
| Send data to <em class="parameter"><code>address</code></em> on <em class="parameter"><code>socket</code></em>. This is the most complicated and |
| fully-featured version of this call. For easier use, see |
| <a class="link" href="GSocket.html#g-socket-send" title="g_socket_send ()"><code class="function">g_socket_send()</code></a> and <a class="link" href="GSocket.html#g-socket-send-to" title="g_socket_send_to ()"><code class="function">g_socket_send_to()</code></a>. |
| </p> |
| <p> |
| If <em class="parameter"><code>address</code></em> is <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> then the message is sent to the default receiver |
| (set by <a class="link" href="GSocket.html#g-socket-connect" title="g_socket_connect ()"><code class="function">g_socket_connect()</code></a>). |
| </p> |
| <p> |
| <em class="parameter"><code>vectors</code></em> must point to an array of <a class="link" href="GSocket.html#GOutputVector" title="GOutputVector"><span class="type">GOutputVector</span></a> structs and |
| <em class="parameter"><code>num_vectors</code></em> must be the length of this array. (If <em class="parameter"><code>num_vectors</code></em> is -1, |
| then <em class="parameter"><code>vectors</code></em> is assumed to be terminated by a <a class="link" href="GSocket.html#GOutputVector" title="GOutputVector"><span class="type">GOutputVector</span></a> with a |
| <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> buffer pointer.) The <a class="link" href="GSocket.html#GOutputVector" title="GOutputVector"><span class="type">GOutputVector</span></a> structs describe the buffers |
| that the sent data will be gathered from. Using multiple |
| <a class="link" href="GSocket.html#GOutputVector" title="GOutputVector"><span class="type">GOutputVector</span></a>s is more memory-efficient than manually copying |
| data from multiple sources into a single buffer, and more |
| network-efficient than making multiple calls to <a class="link" href="GSocket.html#g-socket-send" title="g_socket_send ()"><code class="function">g_socket_send()</code></a>. |
| </p> |
| <p> |
| <em class="parameter"><code>messages</code></em>, if non-<a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, is taken to point to an array of <em class="parameter"><code>num_messages</code></em> |
| <a class="link" href="GSocketControlMessage.html" title="GSocketControlMessage"><span class="type">GSocketControlMessage</span></a> instances. These correspond to the control |
| messages to be sent on the socket. |
| If <em class="parameter"><code>num_messages</code></em> is -1 then <em class="parameter"><code>messages</code></em> is treated as a <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>-terminated |
| array. |
| </p> |
| <p> |
| <em class="parameter"><code>flags</code></em> modify how the message is sent. The commonly available arguments |
| for this are available in the <a class="link" href="GSocket.html#GSocketMsgFlags" title="enum GSocketMsgFlags"><span class="type">GSocketMsgFlags</span></a> enum, but the |
| values there are the same as the system values, and the flags |
| are passed in as-is, so you can pass in system-specific flags too. |
| </p> |
| <p> |
| If the socket is in blocking mode the call will block until there is |
| space for the data in the socket queue. If there is no space available |
| and the socket is in non-blocking mode a <a class="link" href="gio-GIOError.html#G-IO-ERROR-WOULD-BLOCK:CAPS"><code class="literal">G_IO_ERROR_WOULD_BLOCK</code></a> error |
| will be returned. To be notified when space is available, wait for the |
| <a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#G-IO-OUT:CAPS"><code class="literal">G_IO_OUT</code></a> condition. Note though that you may still receive |
| <a class="link" href="gio-GIOError.html#G-IO-ERROR-WOULD-BLOCK:CAPS"><code class="literal">G_IO_ERROR_WOULD_BLOCK</code></a> from <a class="link" href="GSocket.html#g-socket-send" title="g_socket_send ()"><code class="function">g_socket_send()</code></a> even if you were previously |
| notified of a <a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#G-IO-OUT:CAPS"><code class="literal">G_IO_OUT</code></a> condition. (On Windows in particular, this is |
| very common due to the way the underlying APIs work.) |
| </p> |
| <p> |
| On error -1 is returned and <em class="parameter"><code>error</code></em> is set accordingly. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>address</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a>, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>vectors</code></em> :</span></p></td> |
| <td>an array of <a class="link" href="GSocket.html#GOutputVector" title="GOutputVector"><span class="type">GOutputVector</span></a> structs |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>num_vectors</code></em> :</span></p></td> |
| <td>the number of elements in <em class="parameter"><code>vectors</code></em>, or -1 |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>messages</code></em> :</span></p></td> |
| <td>a pointer to an array of <a href="GSocketControlMessage.html"><span class="type">GSocketControlMessages</span></a>, or |
| <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>num_messages</code></em> :</span></p></td> |
| <td>number of elements in <em class="parameter"><code>messages</code></em>, or -1. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>flags</code></em> :</span></p></td> |
| <td>an int containing <a class="link" href="GSocket.html#GSocketMsgFlags" title="enum GSocketMsgFlags"><span class="type">GSocketMsgFlags</span></a> flags |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td> |
| <td>a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td> |
| <td> |
| <a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> Number of bytes written (which may be less than <em class="parameter"><code>size</code></em>), or -1 |
| on error |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_close ()"> |
| <a name="g-socket-close"></a><h3>g_socket_close ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_socket_close (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p> |
| Closes the socket, shutting down any active connection. |
| </p> |
| <p> |
| Closing a socket does not wait for all outstanding I/O operations |
| to finish, so the caller should not rely on them to be guaranteed |
| to complete even if the close returns with no error. |
| </p> |
| <p> |
| Once the socket is closed, all other operations will return |
| <a class="link" href="gio-GIOError.html#G-IO-ERROR-CLOSED:CAPS"><code class="literal">G_IO_ERROR_CLOSED</code></a>. Closing a socket multiple times will not |
| return an error. |
| </p> |
| <p> |
| Sockets will be automatically closed when the last reference |
| is dropped, but you might want to call this function to make sure |
| resources are released as early as possible. |
| </p> |
| <p> |
| Beware that due to the way that TCP works, it is possible for |
| recently-sent data to be lost if either you close a socket while the |
| <a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#G-IO-IN:CAPS"><code class="literal">G_IO_IN</code></a> condition is set, or else if the remote connection tries to |
| send something to you after you close the socket but before it has |
| finished reading all of the data you sent. There is no easy generic |
| way to avoid this problem; the easiest fix is to design the network |
| protocol such that the client will never send data "out of turn". |
| Another solution is for the server to half-close the connection by |
| calling <a class="link" href="GSocket.html#g-socket-shutdown" title="g_socket_shutdown ()"><code class="function">g_socket_shutdown()</code></a> with only the <em class="parameter"><code>shutdown_write</code></em> flag set, |
| and then wait for the client to notice this and close its side of the |
| connection, after which the server can safely call <a class="link" href="GSocket.html#g-socket-close" title="g_socket_close ()"><code class="function">g_socket_close()</code></a>. |
| (This is what <a class="link" href="GSocketConnection.html#GTcpConnection"><span class="type">GTcpConnection</span></a> does if you call |
| <a class="link" href="GSocketConnection.html#g-tcp-connection-set-graceful-disconnect" title="g_tcp_connection_set_graceful_disconnect ()"><code class="function">g_tcp_connection_set_graceful_disconnect()</code></a>. But of course, this |
| only works if the client will close its connection after the server |
| does.) |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td> |
| <td> |
| <a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> on error |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_is_closed ()"> |
| <a name="g-socket-is-closed"></a><h3>g_socket_is_closed ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_socket_is_closed (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>);</pre> |
| <p> |
| Checks whether a socket is closed. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if socket is closed, <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_shutdown ()"> |
| <a name="g-socket-shutdown"></a><h3>g_socket_shutdown ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_socket_shutdown (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> shutdown_read</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> shutdown_write</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p> |
| Shut down part of a full-duplex connection. |
| </p> |
| <p> |
| If <em class="parameter"><code>shutdown_read</code></em> is <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> then the recieving side of the connection |
| is shut down, and further reading is disallowed. |
| </p> |
| <p> |
| If <em class="parameter"><code>shutdown_write</code></em> is <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> then the sending side of the connection |
| is shut down, and further writing is disallowed. |
| </p> |
| <p> |
| It is allowed for both <em class="parameter"><code>shutdown_read</code></em> and <em class="parameter"><code>shutdown_write</code></em> to be <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>. |
| </p> |
| <p> |
| One example where this is used is graceful disconnect for TCP connections |
| where you close the sending side, then wait for the other side to close |
| the connection, thus ensuring that the other side saw all sent data. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>shutdown_read</code></em> :</span></p></td> |
| <td>whether to shut down the read side |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>shutdown_write</code></em> :</span></p></td> |
| <td>whether to shut down the write side |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td> |
| <td> |
| <a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> on error |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_is_connected ()"> |
| <a name="g-socket-is-connected"></a><h3>g_socket_is_connected ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_socket_is_connected (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>);</pre> |
| <p> |
| Check whether the socket is connected. This is only useful for |
| connection-oriented sockets. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if socket is connected, <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_create_source ()"> |
| <a name="g-socket-create-source"></a><h3>g_socket_create_source ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSource"><span class="returnvalue">GSource</span></a> * g_socket_create_source (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#GIOCondition"><span class="type">GIOCondition</span></a> condition</code></em>, |
| <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>);</pre> |
| <p> |
| Creates a <a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSource"><code class="literal">GSource</code></a> that can be attached to a <a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GMainContext"><code class="literal">GMainContext</code></a> to monitor |
| for the availibility of the specified <em class="parameter"><code>condition</code></em> on the socket. |
| </p> |
| <p> |
| The callback on the source is of the <a class="link" href="GSocket.html#GSocketSourceFunc" title="GSocketSourceFunc ()"><span class="type">GSocketSourceFunc</span></a> type. |
| </p> |
| <p> |
| It is meaningless to specify <a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#G-IO-ERR:CAPS"><code class="literal">G_IO_ERR</code></a> or <a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#G-IO-HUP:CAPS"><code class="literal">G_IO_HUP</code></a> in condition; |
| these conditions will always be reported output if they are true. |
| </p> |
| <p> |
| <em class="parameter"><code>cancellable</code></em> if not <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> can be used to cancel the source, which will |
| cause the source to trigger, reporting the current condition (which |
| is likely 0 unless cancellation happened at the same time as a |
| condition change). You can check for this in the callback using |
| <a class="link" href="GCancellable.html#g-cancellable-is-cancelled" title="g_cancellable_is_cancelled ()"><code class="function">g_cancellable_is_cancelled()</code></a>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>condition</code></em> :</span></p></td> |
| <td>a <a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#GIOCondition"><span class="type">GIOCondition</span></a> mask to monitor |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td> |
| <td>a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> a newly allocated <a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSource"><code class="literal">GSource</code></a>, free with <a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#g-source-unref"><code class="function">g_source_unref()</code></a>. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_condition_check ()"> |
| <a name="g-socket-condition-check"></a><h3>g_socket_condition_check ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#GIOCondition"><span class="returnvalue">GIOCondition</span></a> g_socket_condition_check (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#GIOCondition"><span class="type">GIOCondition</span></a> condition</code></em>);</pre> |
| <p> |
| Checks on the readiness of <em class="parameter"><code>socket</code></em> to perform operations. |
| The operations specified in <em class="parameter"><code>condition</code></em> are checked for and masked |
| against the currently-satisfied conditions on <em class="parameter"><code>socket</code></em>. The result |
| is returned. |
| </p> |
| <p> |
| It is meaningless to specify <a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#G-IO-ERR:CAPS"><code class="literal">G_IO_ERR</code></a> or <a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#G-IO-HUP:CAPS"><code class="literal">G_IO_HUP</code></a> in condition; |
| these conditions will always be set in the output if they are true. |
| </p> |
| <p> |
| This call never blocks. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>condition</code></em> :</span></p></td> |
| <td>a <a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#GIOCondition"><span class="type">GIOCondition</span></a> mask to check |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the <em class="parameter"><code>GIOCondition</code></em> mask of the current state |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_condition_wait ()"> |
| <a name="g-socket-condition-wait"></a><h3>g_socket_condition_wait ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_socket_condition_wait (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#GIOCondition"><span class="type">GIOCondition</span></a> condition</code></em>, |
| <em class="parameter"><code><a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p> |
| Waits for <em class="parameter"><code>condition</code></em> to become true on <em class="parameter"><code>socket</code></em>. When the condition |
| is met, <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> is returned. |
| </p> |
| <p> |
| If <em class="parameter"><code>cancellable</code></em> is cancelled before the condition is met then <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> |
| is returned and <em class="parameter"><code>error</code></em>, if non-<a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, is set to <a class="link" href="gio-GIOError.html#G-IO-ERROR-CANCELLED:CAPS"><code class="literal">G_IO_ERROR_CANCELLED</code></a>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>condition</code></em> :</span></p></td> |
| <td>a <a href="/usr/share/gtk-doc/html/glib/glib-IO-Channels.html#GIOCondition"><span class="type">GIOCondition</span></a> mask to wait for |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td> |
| <td>a <a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a>, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td> |
| <td>a <a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> pointer, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the condition was met, <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_set_listen_backlog ()"> |
| <a name="g-socket-set-listen-backlog"></a><h3>g_socket_set_listen_backlog ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> g_socket_set_listen_backlog (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> backlog</code></em>);</pre> |
| <p> |
| Sets the maximum number of outstanding connections allowed |
| when listening on this socket. If more clients than this are |
| connecting to the socket and the application is not handling them |
| on time then the new connections will be refused. |
| </p> |
| <p> |
| Note that this must be called before <a class="link" href="GSocket.html#g-socket-listen" title="g_socket_listen ()"><code class="function">g_socket_listen()</code></a> and has no |
| effect if called after that. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>backlog</code></em> :</span></p></td> |
| <td>the maximum number of pending connections. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_get_listen_backlog ()"> |
| <a name="g-socket-get-listen-backlog"></a><h3>g_socket_get_listen_backlog ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a> g_socket_get_listen_backlog (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>);</pre> |
| <p> |
| Gets the listen backlog setting of the socket. For details on this, |
| see <a class="link" href="GSocket.html#g-socket-set-listen-backlog" title="g_socket_set_listen_backlog ()"><code class="function">g_socket_set_listen_backlog()</code></a>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the maximum number of pending connections. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_get_blocking ()"> |
| <a name="g-socket-get-blocking"></a><h3>g_socket_get_blocking ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_socket_get_blocking (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>);</pre> |
| <p> |
| Gets the blocking mode of the socket. For details on blocking I/O, |
| see <a class="link" href="GSocket.html#g-socket-set-blocking" title="g_socket_set_blocking ()"><code class="function">g_socket_set_blocking()</code></a>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if blocking I/O is used, <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_set_blocking ()"> |
| <a name="g-socket-set-blocking"></a><h3>g_socket_set_blocking ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> g_socket_set_blocking (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> blocking</code></em>);</pre> |
| <p> |
| Sets the blocking mode of the socket. In blocking mode |
| all operations block until they succeed or there is an error. In |
| non-blocking mode all functions return results immediately or |
| with a <a class="link" href="gio-GIOError.html#G-IO-ERROR-WOULD-BLOCK:CAPS"><code class="literal">G_IO_ERROR_WOULD_BLOCK</code></a> error. |
| </p> |
| <p> |
| All sockets are created in blocking mode. However, note that the |
| platform level socket is always non-blocking, and blocking mode |
| is a GSocket level feature. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>blocking</code></em> :</span></p></td> |
| <td>Whether to use blocking I/O or not. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_get_keepalive ()"> |
| <a name="g-socket-get-keepalive"></a><h3>g_socket_get_keepalive ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_socket_get_keepalive (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>);</pre> |
| <p> |
| Gets the keepalive mode of the socket. For details on this, |
| see <a class="link" href="GSocket.html#g-socket-set-keepalive" title="g_socket_set_keepalive ()"><code class="function">g_socket_set_keepalive()</code></a>. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if keepalive is active, <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_set_keepalive ()"> |
| <a name="g-socket-set-keepalive"></a><h3>g_socket_set_keepalive ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> g_socket_set_keepalive (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> keepalive</code></em>);</pre> |
| <p> |
| Sets or unsets the <code class="literal">SO_KEEPALIVE</code> flag on the underlying socket. When |
| this flag is set on a socket, the system will attempt to verify that the |
| remote socket endpoint is still present if a sufficiently long period of |
| time passes with no data being exchanged. If the system is unable to |
| verify the presence of the remote endpoint, it will automatically close |
| the connection. |
| </p> |
| <p> |
| This option is only functional on certain kinds of sockets. (Notably, |
| <a class="link" href="GSocket.html#G-SOCKET-PROTOCOL-TCP:CAPS"><code class="literal">G_SOCKET_PROTOCOL_TCP</code></a> sockets.) |
| </p> |
| <p> |
| The exact time between pings is system- and protocol-dependent, but will |
| normally be at least two hours. Most commonly, you would set this flag |
| on a server socket if you want to allow clients to remain idle for long |
| periods of time, but also want to ensure that connections are eventually |
| garbage-collected if clients crash or become unreachable. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>keepalive</code></em> :</span></p></td> |
| <td>Value for the keepalive flag |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_get_family ()"> |
| <a name="g-socket-get-family"></a><h3>g_socket_get_family ()</h3> |
| <pre class="programlisting"><a class="link" href="GSocketAddress.html#GSocketFamily" title="enum GSocketFamily"><span class="returnvalue">GSocketFamily</span></a> g_socket_get_family (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>);</pre> |
| <p> |
| Gets the socket family of the socket. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> a <a class="link" href="GSocketAddress.html#GSocketFamily" title="enum GSocketFamily"><span class="type">GSocketFamily</span></a> |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_get_fd ()"> |
| <a name="g-socket-get-fd"></a><h3>g_socket_get_fd ()</h3> |
| <pre class="programlisting"><span class="returnvalue">int</span> g_socket_get_fd (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>);</pre> |
| <p> |
| Returns the underlying OS socket object. On unix this |
| is a socket file descriptor, and on windows this is |
| a Winsock2 SOCKET handle. This may be useful for |
| doing platform specific or otherwise unusual operations |
| on the socket. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> the file descriptor of the socket. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_get_local_address ()"> |
| <a name="g-socket-get-local-address"></a><h3>g_socket_get_local_address ()</h3> |
| <pre class="programlisting"><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="returnvalue">GSocketAddress</span></a> * g_socket_get_local_address (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p> |
| Try to get the local address of a bound socket. This is only |
| useful if the socket has been bound to a local address, |
| either explicitly or implicitly when connecting. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td> |
| <td> |
| <a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on error. |
| Free the returned object with <a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a>. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_get_protocol ()"> |
| <a name="g-socket-get-protocol"></a><h3>g_socket_get_protocol ()</h3> |
| <pre class="programlisting"><a class="link" href="GSocket.html#GSocketProtocol" title="enum GSocketProtocol"><span class="returnvalue">GSocketProtocol</span></a> g_socket_get_protocol (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>);</pre> |
| <p> |
| Gets the socket protocol id the socket was created with. |
| In case the protocol is unknown, -1 is returned. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> a protocol id, or -1 if unknown |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_get_remote_address ()"> |
| <a name="g-socket-get-remote-address"></a><h3>g_socket_get_remote_address ()</h3> |
| <pre class="programlisting"><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="returnvalue">GSocketAddress</span></a> * g_socket_get_remote_address (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>, |
| <em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p> |
| Try to get the remove address of a connected socket. This is only |
| useful for connection oriented sockets that have been connected. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td> |
| <td> |
| <a href="/usr/share/gtk-doc/html/glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on error. |
| Free the returned object with <a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a>. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_get_socket_type ()"> |
| <a name="g-socket-get-socket-type"></a><h3>g_socket_get_socket_type ()</h3> |
| <pre class="programlisting"><a class="link" href="GSocket.html#GSocketType" title="enum GSocketType"><span class="returnvalue">GSocketType</span></a> g_socket_get_socket_type (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>);</pre> |
| <p> |
| Gets the socket type of the socket. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> a <a class="link" href="GSocket.html#GSocketType" title="enum GSocketType"><span class="type">GSocketType</span></a> |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="g_socket_speaks_ipv4 ()"> |
| <a name="g-socket-speaks-ipv4"></a><h3>g_socket_speaks_ipv4 ()</h3> |
| <pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> g_socket_speaks_ipv4 (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>);</pre> |
| <p> |
| Checks if a socket is capable of speaking IPv4. |
| </p> |
| <p> |
| IPv4 sockets are capable of speaking IPv4. On some operating systems |
| and under some combinations of circumstances IPv6 sockets are also |
| capable of speaking IPv4. See RFC 3493 section 3.7 for more |
| information. |
| </p> |
| <p> |
| No other types of sockets are currently considered as being capable |
| of speaking IPv4. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>socket</code></em> :</span></p></td> |
| <td>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if this socket can be used with IPv4. |
| |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.22</p> |
| </div> |
| </div> |
| <div class="refsect1" title="Property Details"> |
| <a name="GSocket.property-details"></a><h2>Property Details</h2> |
| <div class="refsect2" title='The "blocking" property'> |
| <a name="GSocket--blocking"></a><h3>The <code class="literal">"blocking"</code> property</h3> |
| <pre class="programlisting"> "blocking" <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> : Read / Write</pre> |
| <p>Whether or not I/O on this socket is blocking.</p> |
| <p>Default value: TRUE</p> |
| </div> |
| <hr> |
| <div class="refsect2" title='The "family" property'> |
| <a name="GSocket--family"></a><h3>The <code class="literal">"family"</code> property</h3> |
| <pre class="programlisting"> "family" <a class="link" href="GSocketAddress.html#GSocketFamily" title="enum GSocketFamily"><span class="type">GSocketFamily</span></a> : Read / Write / Construct Only</pre> |
| <p>The sockets address family.</p> |
| <p>Default value: G_SOCKET_FAMILY_INVALID</p> |
| </div> |
| <hr> |
| <div class="refsect2" title='The "fd" property'> |
| <a name="GSocket--fd"></a><h3>The <code class="literal">"fd"</code> property</h3> |
| <pre class="programlisting"> "fd" <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> : Read / Write / Construct Only</pre> |
| <p>The sockets file descriptor.</p> |
| <p>Default value: -1</p> |
| </div> |
| <hr> |
| <div class="refsect2" title='The "keepalive" property'> |
| <a name="GSocket--keepalive"></a><h3>The <code class="literal">"keepalive"</code> property</h3> |
| <pre class="programlisting"> "keepalive" <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> : Read / Write</pre> |
| <p>Keep connection alive by sending periodic pings.</p> |
| <p>Default value: FALSE</p> |
| </div> |
| <hr> |
| <div class="refsect2" title='The "listen-backlog" property'> |
| <a name="GSocket--listen-backlog"></a><h3>The <code class="literal">"listen-backlog"</code> property</h3> |
| <pre class="programlisting"> "listen-backlog" <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> : Read / Write</pre> |
| <p>Outstanding connections in the listen queue.</p> |
| <p>Allowed values: [0,128]</p> |
| <p>Default value: 10</p> |
| </div> |
| <hr> |
| <div class="refsect2" title='The "local-address" property'> |
| <a name="GSocket--local-address"></a><h3>The <code class="literal">"local-address"</code> property</h3> |
| <pre class="programlisting"> "local-address" <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a>* : Read</pre> |
| <p>The local address the socket is bound to.</p> |
| </div> |
| <hr> |
| <div class="refsect2" title='The "protocol" property'> |
| <a name="GSocket--protocol"></a><h3>The <code class="literal">"protocol"</code> property</h3> |
| <pre class="programlisting"> "protocol" <a class="link" href="GSocket.html#GSocketProtocol" title="enum GSocketProtocol"><span class="type">GSocketProtocol</span></a> : Read / Write / Construct Only</pre> |
| <p>The id of the protocol to use, or -1 for unknown.</p> |
| <p>Default value: G_SOCKET_PROTOCOL_UNKNOWN</p> |
| </div> |
| <hr> |
| <div class="refsect2" title='The "remote-address" property'> |
| <a name="GSocket--remote-address"></a><h3>The <code class="literal">"remote-address"</code> property</h3> |
| <pre class="programlisting"> "remote-address" <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a>* : Read</pre> |
| <p>The remote address the socket is connected to.</p> |
| </div> |
| <hr> |
| <div class="refsect2" title='The "type" property'> |
| <a name="GSocket--type"></a><h3>The <code class="literal">"type"</code> property</h3> |
| <pre class="programlisting"> "type" <a class="link" href="GSocket.html#GSocketType" title="enum GSocketType"><span class="type">GSocketType</span></a> : Read / Write / Construct Only</pre> |
| <p>The sockets type.</p> |
| <p>Default value: G_SOCKET_TYPE_STREAM</p> |
| </div> |
| </div> |
| <div class="refsect1" title="See Also"> |
| <a name="GSocket.see-also"></a><h2>See Also</h2> |
| <a class="link" href="GInitable.html" title="GInitable"><span class="type">GInitable</span></a> |
| </div> |
| </div> |
| <div class="footer"> |
| <hr> |
| Generated by GTK-Doc V1.14</div> |
| </body> |
| </html> |