| <!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: GIO Reference Manual</title> |
| <meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> |
| <link rel="home" href="index.html" title="GIO Reference Manual"> |
| <link rel="up" href="networking.html" title="Low-level network support"> |
| <link rel="prev" href="networking.html" title="Low-level network support"> |
| <link rel="next" href="GDatagramBased.html" title="GDatagramBased"> |
| <meta name="generator" content="GTK-Doc V1.25.1 (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="5"><tr valign="middle"> |
| <td width="100%" align="left" class="shortcuts"> |
| <a href="#" class="shortcut">Top</a><span id="nav_description"> <span class="dim">|</span> |
| <a href="#GSocket.description" class="shortcut">Description</a></span><span id="nav_hierarchy"> <span class="dim">|</span> |
| <a href="#GSocket.object-hierarchy" class="shortcut">Object Hierarchy</a></span><span id="nav_interfaces"> <span class="dim">|</span> |
| <a href="#GSocket.implemented-interfaces" class="shortcut">Implemented Interfaces</a></span><span id="nav_properties"> <span class="dim">|</span> |
| <a href="#GSocket.properties" class="shortcut">Properties</a></span> |
| </td> |
| <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td> |
| <td><a accesskey="u" href="networking.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td> |
| <td><a accesskey="p" href="networking.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td> |
| <td><a accesskey="n" href="GDatagramBased.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td> |
| </tr></table> |
| <div class="refentry"> |
| <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 class="gallery_image" valign="top" align="right"></td> |
| </tr></table></div> |
| <div class="refsect1"> |
| <a name="GSocket.functions"></a><h2>Functions</h2> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="functions_return"> |
| <col class="functions_name"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <span class="c_punctuation">(</span><a class="link" href="GSocket.html#GSocketSourceFunc" title="GSocketSourceFunc ()">*GSocketSourceFunc</a><span class="c_punctuation">)</span> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="GSocket.html" title="GSocket"><span class="returnvalue">GSocket</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-new" title="g_socket_new ()">g_socket_new</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="GSocket.html" title="GSocket"><span class="returnvalue">GSocket</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-new-from-fd" title="g_socket_new_from_fd ()">g_socket_new_from_fd</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-bind" title="g_socket_bind ()">g_socket_bind</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-listen" title="g_socket_listen ()">g_socket_listen</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="GSocket.html" title="GSocket"><span class="returnvalue">GSocket</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-accept" title="g_socket_accept ()">g_socket_accept</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-connect" title="g_socket_connect ()">g_socket_connect</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-check-connect-result" title="g_socket_check_connect_result ()">g_socket_check_connect_result</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-receive" title="g_socket_receive ()">g_socket_receive</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-receive-from" title="g_socket_receive_from ()">g_socket_receive_from</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-receive-message" title="g_socket_receive_message ()">g_socket_receive_message</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-receive-messages" title="g_socket_receive_messages ()">g_socket_receive_messages</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-receive-with-blocking" title="g_socket_receive_with_blocking ()">g_socket_receive_with_blocking</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-send" title="g_socket_send ()">g_socket_send</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-send-to" title="g_socket_send_to ()">g_socket_send_to</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-send-message" title="g_socket_send_message ()">g_socket_send_message</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-send-messages" title="g_socket_send_messages ()">g_socket_send_messages</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-send-with-blocking" title="g_socket_send_with_blocking ()">g_socket_send_with_blocking</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-close" title="g_socket_close ()">g_socket_close</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-is-closed" title="g_socket_is_closed ()">g_socket_is_closed</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-shutdown" title="g_socket_shutdown ()">g_socket_shutdown</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-is-connected" title="g_socket_is_connected ()">g_socket_is_connected</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-The-Main-Event-Loop.html#GSource"><span class="returnvalue">GSource</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-create-source" title="g_socket_create_source ()">g_socket_create_source</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-IO-Channels.html#GIOCondition"><span class="returnvalue">GIOCondition</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-condition-check" title="g_socket_condition_check ()">g_socket_condition_check</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-condition-wait" title="g_socket_condition_wait ()">g_socket_condition_wait</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-condition-timed-wait" title="g_socket_condition_timed_wait ()">g_socket_condition_timed_wait</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-get-available-bytes" title="g_socket_get_available_bytes ()">g_socket_get_available_bytes</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-set-listen-backlog" title="g_socket_set_listen_backlog ()">g_socket_set_listen_backlog</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-get-listen-backlog" title="g_socket_get_listen_backlog ()">g_socket_get_listen_backlog</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-get-blocking" title="g_socket_get_blocking ()">g_socket_get_blocking</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-set-blocking" title="g_socket_set_blocking ()">g_socket_set_blocking</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-get-keepalive" title="g_socket_get_keepalive ()">g_socket_get_keepalive</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-set-keepalive" title="g_socket_set_keepalive ()">g_socket_set_keepalive</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#guint"><span class="returnvalue">guint</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-get-timeout" title="g_socket_get_timeout ()">g_socket_get_timeout</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-set-timeout" title="g_socket_set_timeout ()">g_socket_set_timeout</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-set-ttl" title="g_socket_set_ttl ()">g_socket_set_ttl</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#guint"><span class="returnvalue">guint</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-get-ttl" title="g_socket_get_ttl ()">g_socket_get_ttl</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-get-broadcast" title="g_socket_get_broadcast ()">g_socket_get_broadcast</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-set-broadcast" title="g_socket_set_broadcast ()">g_socket_set_broadcast</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-get-option" title="g_socket_get_option ()">g_socket_get_option</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-set-option" title="g_socket_set_option ()">g_socket_set_option</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="GSocketAddress.html#GSocketFamily" title="enum GSocketFamily"><span class="returnvalue">GSocketFamily</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-get-family" title="g_socket_get_family ()">g_socket_get_family</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">int</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-get-fd" title="g_socket_get_fd ()">g_socket_get_fd</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="returnvalue">GSocketAddress</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-get-local-address" title="g_socket_get_local_address ()">g_socket_get_local_address</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="GSocket.html#GSocketProtocol" title="enum GSocketProtocol"><span class="returnvalue">GSocketProtocol</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-get-protocol" title="g_socket_get_protocol ()">g_socket_get_protocol</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="returnvalue">GSocketAddress</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-get-remote-address" title="g_socket_get_remote_address ()">g_socket_get_remote_address</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="GSocket.html#GSocketType" title="enum GSocketType"><span class="returnvalue">GSocketType</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-get-socket-type" title="g_socket_get_socket_type ()">g_socket_get_socket_type</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-speaks-ipv4" title="g_socket_speaks_ipv4 ()">g_socket_speaks_ipv4</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a class="link" href="GCredentials.html" title="GCredentials"><span class="returnvalue">GCredentials</span></a> * |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-get-credentials" title="g_socket_get_credentials ()">g_socket_get_credentials</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-join-multicast-group" title="g_socket_join_multicast_group ()">g_socket_join_multicast_group</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-leave-multicast-group" title="g_socket_leave_multicast_group ()">g_socket_leave_multicast_group</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-get-multicast-loopback" title="g_socket_get_multicast_loopback ()">g_socket_get_multicast_loopback</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-set-multicast-loopback" title="g_socket_set_multicast_loopback ()">g_socket_set_multicast_loopback</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <a href="../glib-Basic-Types.html#guint"><span class="returnvalue">guint</span></a> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-get-multicast-ttl" title="g_socket_get_multicast_ttl ()">g_socket_get_multicast_ttl</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| <tr> |
| <td class="function_type"> |
| <span class="returnvalue">void</span> |
| </td> |
| <td class="function_name"> |
| <a class="link" href="GSocket.html#g-socket-set-multicast-ttl" title="g_socket_set_multicast_ttl ()">g_socket_set_multicast_ttl</a> <span class="c_punctuation">()</span> |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect1"> |
| <a name="GSocket.properties"></a><h2>Properties</h2> |
| <div class="informaltable"><table class="informaltable" border="0"> |
| <colgroup> |
| <col width="150px" class="properties_type"> |
| <col width="300px" class="properties_name"> |
| <col width="200px" class="properties_flags"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="property_type"><a href="../glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a></td> |
| <td class="property_name"><a class="link" href="GSocket.html#GSocket--blocking" title="The “blocking” property">blocking</a></td> |
| <td class="property_flags">Read / Write</td> |
| </tr> |
| <tr> |
| <td class="property_type"><a href="../glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a></td> |
| <td class="property_name"><a class="link" href="GSocket.html#GSocket--broadcast" title="The “broadcast” property">broadcast</a></td> |
| <td class="property_flags">Read / Write</td> |
| </tr> |
| <tr> |
| <td class="property_type"><a class="link" href="GSocketAddress.html#GSocketFamily" title="enum GSocketFamily"><span class="type">GSocketFamily</span></a></td> |
| <td class="property_name"><a class="link" href="GSocket.html#GSocket--family" title="The “family” property">family</a></td> |
| <td class="property_flags">Read / Write / Construct Only</td> |
| </tr> |
| <tr> |
| <td class="property_type"><a href="../glib-Basic-Types.html#gint"><span class="type">gint</span></a></td> |
| <td class="property_name"><a class="link" href="GSocket.html#GSocket--fd" title="The “fd” property">fd</a></td> |
| <td class="property_flags">Read / Write / Construct Only</td> |
| </tr> |
| <tr> |
| <td class="property_type"><a href="../glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a></td> |
| <td class="property_name"><a class="link" href="GSocket.html#GSocket--keepalive" title="The “keepalive” property">keepalive</a></td> |
| <td class="property_flags">Read / Write</td> |
| </tr> |
| <tr> |
| <td class="property_type"><a href="../glib-Basic-Types.html#gint"><span class="type">gint</span></a></td> |
| <td class="property_name"><a class="link" href="GSocket.html#GSocket--listen-backlog" title="The “listen-backlog” property">listen-backlog</a></td> |
| <td class="property_flags">Read / Write</td> |
| </tr> |
| <tr> |
| <td class="property_type"> |
| <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *</td> |
| <td class="property_name"><a class="link" href="GSocket.html#GSocket--local-address" title="The “local-address” property">local-address</a></td> |
| <td class="property_flags">Read</td> |
| </tr> |
| <tr> |
| <td class="property_type"><a href="../glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a></td> |
| <td class="property_name"><a class="link" href="GSocket.html#GSocket--multicast-loopback" title="The “multicast-loopback” property">multicast-loopback</a></td> |
| <td class="property_flags">Read / Write</td> |
| </tr> |
| <tr> |
| <td class="property_type"><a href="../glib-Basic-Types.html#guint"><span class="type">guint</span></a></td> |
| <td class="property_name"><a class="link" href="GSocket.html#GSocket--multicast-ttl" title="The “multicast-ttl” property">multicast-ttl</a></td> |
| <td class="property_flags">Read / Write</td> |
| </tr> |
| <tr> |
| <td class="property_type"><a class="link" href="GSocket.html#GSocketProtocol" title="enum GSocketProtocol"><span class="type">GSocketProtocol</span></a></td> |
| <td class="property_name"><a class="link" href="GSocket.html#GSocket--protocol" title="The “protocol” property">protocol</a></td> |
| <td class="property_flags">Read / Write / Construct Only</td> |
| </tr> |
| <tr> |
| <td class="property_type"> |
| <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *</td> |
| <td class="property_name"><a class="link" href="GSocket.html#GSocket--remote-address" title="The “remote-address” property">remote-address</a></td> |
| <td class="property_flags">Read</td> |
| </tr> |
| <tr> |
| <td class="property_type"><a href="../glib-Basic-Types.html#guint"><span class="type">guint</span></a></td> |
| <td class="property_name"><a class="link" href="GSocket.html#GSocket--timeout" title="The “timeout” property">timeout</a></td> |
| <td class="property_flags">Read / Write</td> |
| </tr> |
| <tr> |
| <td class="property_type"><a href="../glib-Basic-Types.html#guint"><span class="type">guint</span></a></td> |
| <td class="property_name"><a class="link" href="GSocket.html#GSocket--ttl" title="The “ttl” property">ttl</a></td> |
| <td class="property_flags">Read / Write</td> |
| </tr> |
| <tr> |
| <td class="property_type"><a class="link" href="GSocket.html#GSocketType" title="enum GSocketType"><span class="type">GSocketType</span></a></td> |
| <td class="property_name"><a class="link" href="GSocket.html#GSocket--type" title="The “type” property">type</a></td> |
| <td class="property_flags">Read / Write / Construct Only</td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect1"> |
| <a name="GSocket.other"></a><h2>Types and Values</h2> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="name"> |
| <col class="description"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="datatype_keyword"> </td> |
| <td class="function_name"><a class="link" href="GSocket.html#GSocket-struct" title="GSocket">GSocket</a></td> |
| </tr> |
| <tr> |
| <td class="datatype_keyword">enum</td> |
| <td class="function_name"><a class="link" href="GSocket.html#GSocketType" title="enum GSocketType">GSocketType</a></td> |
| </tr> |
| <tr> |
| <td class="datatype_keyword">enum</td> |
| <td class="function_name"><a class="link" href="GSocket.html#GSocketProtocol" title="enum GSocketProtocol">GSocketProtocol</a></td> |
| </tr> |
| <tr> |
| <td class="datatype_keyword">enum</td> |
| <td class="function_name"><a class="link" href="GSocket.html#GSocketMsgFlags" title="enum GSocketMsgFlags">GSocketMsgFlags</a></td> |
| </tr> |
| <tr> |
| <td class="datatype_keyword">struct</td> |
| <td class="function_name"><a class="link" href="GSocket.html#GInputVector" title="struct GInputVector">GInputVector</a></td> |
| </tr> |
| <tr> |
| <td class="datatype_keyword">struct</td> |
| <td class="function_name"><a class="link" href="GSocket.html#GInputMessage" title="struct GInputMessage">GInputMessage</a></td> |
| </tr> |
| <tr> |
| <td class="datatype_keyword">struct</td> |
| <td class="function_name"><a class="link" href="GSocket.html#GOutputVector" title="struct GOutputVector">GOutputVector</a></td> |
| </tr> |
| <tr> |
| <td class="datatype_keyword">struct</td> |
| <td class="function_name"><a class="link" href="GSocket.html#GOutputMessage" title="struct GOutputMessage">GOutputMessage</a></td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect1"> |
| <a name="GSocket.object-hierarchy"></a><h2>Object Hierarchy</h2> |
| <pre class="screen"> <a href="../gobject-The-Base-Object-Type.html#GObject-struct">GObject</a> |
| <span class="lineart">╰──</span> GSocket |
| </pre> |
| </div> |
| <div class="refsect1"> |
| <a name="GSocket.implemented-interfaces"></a><h2>Implemented Interfaces</h2> |
| <p> |
| GSocket implements |
| <a class="link" href="GInitable.html" title="GInitable">GInitable</a> and <a class="link" href="GDatagramBased.html" title="GDatagramBased">GDatagramBased</a>.</p> |
| </div> |
| <div class="refsect1"> |
| <a name="GSocket.includes"></a><h2>Includes</h2> |
| <pre class="synopsis">#include <gio/gio.h> |
| </pre> |
| </div> |
| <div class="refsect1"> |
| <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="../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="../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 (which don’t take an explicit blocking |
| parameter) 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="../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 href="GSocket.html#GSocket-struct"><span class="type">GSockets</span></a> 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> |
| <p>Like most other APIs in GLib, <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> is not inherently thread safe. To use |
| a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> concurrently from multiple threads, you must implement your own |
| locking.</p> |
| </div> |
| <div class="refsect1"> |
| <a name="GSocket.functions_details"></a><h2>Functions</h2> |
| <div class="refsect2"> |
| <a name="GSocketSourceFunc"></a><h3>GSocketSourceFunc ()</h3> |
| <pre class="programlisting"><a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| <span class="c_punctuation">(</span>*GSocketSourceFunc<span class="c_punctuation">)</span> (<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="../glib-IO-Channels.html#GIOCondition"><span class="type">GIOCondition</span></a> condition</code></em>, |
| <em class="parameter"><code><a href="../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="../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="refsect3"> |
| <a name="GSocketSourceFunc.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>the <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>condition</p></td> |
| <td class="parameter_description"><p>the current condition at the source fired.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>user_data</p></td> |
| <td class="parameter_description"><p>data passed in by the user.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="GSocketSourceFunc.returns"></a><h4>Returns</h4> |
| <p> it should return <a href="../glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> if the source should be removed.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <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="../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="refsect3"> |
| <a name="g-socket-new.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>family</p></td> |
| <td class="parameter_description"><p>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>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>type</p></td> |
| <td class="parameter_description"><p>the socket type to use.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>protocol</p></td> |
| <td class="parameter_description"><p>the id of the protocol to use, or 0 for default.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-new.returns"></a><h4>Returns</h4> |
| <p> a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on error. |
| Free the returned object with <a href="../gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a>.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <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="../glib-Basic-Types.html#gint"><span class="type">gint</span></a> fd</code></em>, |
| <em class="parameter"><code><a href="../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> |
| <p>On success, the returned <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> takes ownership of <em class="parameter"><code>fd</code></em> |
| . On failure, the |
| caller must close <em class="parameter"><code>fd</code></em> |
| themselves.</p> |
| <p>Since GLib 2.46, it is no longer a fatal error to call this on a non-socket |
| descriptor. Instead, a GError will be set with code <a class="link" href="gio-GIOError.html#G-IO-ERROR-FAILED:CAPS"><code class="literal">G_IO_ERROR_FAILED</code></a></p> |
| <div class="refsect3"> |
| <a name="g-socket-new-from-fd.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>fd</p></td> |
| <td class="parameter_description"><p>a native socket file descriptor.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-new-from-fd.returns"></a><h4>Returns</h4> |
| <p> a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on error. |
| Free the returned object with <a href="../gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a>.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-bind"></a><h3>g_socket_bind ()</h3> |
| <pre class="programlisting"><a href="../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="../glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> allow_reuse</code></em>, |
| <em class="parameter"><code><a href="../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>If <em class="parameter"><code>socket</code></em> |
| is a TCP socket, then <em class="parameter"><code>allow_reuse</code></em> |
| controls the setting |
| of the <code class="literal">SO_REUSEADDR</code> socket option; normally it should be <a href="../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="../glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> for client sockets. (Failing to |
| set this flag on a server socket may cause <a class="link" href="GSocket.html#g-socket-bind" title="g_socket_bind ()"><code class="function">g_socket_bind()</code></a> 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> |
| <p>If <em class="parameter"><code>socket</code></em> |
| is a UDP socket, then <em class="parameter"><code>allow_reuse</code></em> |
| determines whether or |
| not other UDP sockets can be bound to the same address at the same |
| time. In particular, you can have several UDP sockets bound to the |
| same address, and they will all receive all of the multicast and |
| broadcast packets sent to that address. (The behavior of unicast |
| UDP packets to an address with multiple listeners is not defined.)</p> |
| <div class="refsect3"> |
| <a name="g-socket-bind.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>address</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> specifying the local address.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>allow_reuse</p></td> |
| <td class="parameter_description"><p>whether to allow reusing this address</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-bind.returns"></a><h4>Returns</h4> |
| <p> <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a href="../glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> on error.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-listen"></a><h3>g_socket_listen ()</h3> |
| <pre class="programlisting"><a href="../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="../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="refsect3"> |
| <a name="g-socket-listen.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-listen.returns"></a><h4>Returns</h4> |
| <p> <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a href="../glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> on error.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <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="../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="../glib-IO-Channels.html#G-IO-IN:CAPS"><code class="literal">G_IO_IN</code></a> condition.</p> |
| <div class="refsect3"> |
| <a name="g-socket-accept.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>cancellable</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-accept.returns"></a><h4>Returns</h4> |
| <p> a new <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on error. |
| Free the returned object with <a href="../gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a>. </p> |
| <p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-connect"></a><h3>g_socket_connect ()</h3> |
| <pre class="programlisting"><a href="../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="../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 must 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="refsect3"> |
| <a name="g-socket-connect.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>address</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> specifying the remote address.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>cancellable</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-connect.returns"></a><h4>Returns</h4> |
| <p> <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if connected, <a href="../glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> on error.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-check-connect-result"></a><h3>g_socket_check_connect_result ()</h3> |
| <pre class="programlisting"><a href="../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="../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="refsect3"> |
| <a name="g-socket-check-connect-result.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-check-connect-result.returns"></a><h4>Returns</h4> |
| <p> <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if no error, <a href="../glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise, setting <em class="parameter"><code>error</code></em> |
| to the error</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-receive"></a><h3>g_socket_receive ()</h3> |
| <pre class="programlisting"><a href="../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="../glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *buffer</code></em>, |
| <em class="parameter"><code><a href="../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="../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="../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, the connection is closed, 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="../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="refsect3"> |
| <a name="g-socket-receive.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>buffer</p></td> |
| <td class="parameter_description"><p> a buffer to |
| read data into (which should be at least <em class="parameter"><code>size</code></em> |
| bytes long). </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=size][<acronym title="Generics and defining elements of containers and arrays."><span class="acronym">element-type</span></acronym> guint8]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>size</p></td> |
| <td class="parameter_description"><p>the number of bytes you want to read from the socket</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>cancellable</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-receive.returns"></a><h4>Returns</h4> |
| <p> Number of bytes read, or 0 if the connection was closed by |
| the peer, or -1 on error</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-receive-from"></a><h3>g_socket_receive_from ()</h3> |
| <pre class="programlisting"><a href="../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="../glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *buffer</code></em>, |
| <em class="parameter"><code><a href="../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="../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="../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="refsect3"> |
| <a name="g-socket-receive-from.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>address</p></td> |
| <td class="parameter_description"><p> a pointer to a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> |
| pointer, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter for returning results. Default is transfer full."><span class="acronym">out</span></acronym>][<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>buffer</p></td> |
| <td class="parameter_description"><p> a buffer to |
| read data into (which should be at least <em class="parameter"><code>size</code></em> |
| bytes long). </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=size][<acronym title="Generics and defining elements of containers and arrays."><span class="acronym">element-type</span></acronym> guint8]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>size</p></td> |
| <td class="parameter_description"><p>the number of bytes you want to read from the socket</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>cancellable</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-receive-from.returns"></a><h4>Returns</h4> |
| <p> Number of bytes read, or 0 if the connection was closed by |
| the peer, or -1 on error</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-receive-message"></a><h3>g_socket_receive_message ()</h3> |
| <pre class="programlisting"><a href="../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="struct GInputVector"><span class="type">GInputVector</span></a> *vectors</code></em>, |
| <em class="parameter"><code><a href="../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="../glib-Basic-Types.html#gint"><span class="type">gint</span></a> *num_messages</code></em>, |
| <em class="parameter"><code><a href="../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="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p>Receive data from a socket. For receiving multiple messages, see |
| <a class="link" href="GSocket.html#g-socket-receive-messages" title="g_socket_receive_messages ()"><code class="function">g_socket_receive_messages()</code></a>; 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="../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="struct 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="struct GInputVector"><span class="type">GInputVector</span></a> with a <a href="../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="../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="../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 or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if no such |
| messages was received. 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="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>-terminated and must be freed |
| by the caller using <a href="../glib-Memory-Allocation.html#g-free"><code class="function">g_free()</code></a> after calling <a href="../gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a> on each |
| element. If <em class="parameter"><code>messages</code></em> |
| is <a href="../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="../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="../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="../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). |
| Flags passed in to the parameter affect the receive operation; flags returned |
| out of it are relevant to the specific returned message.</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, the connection is closed, 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="../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="refsect3"> |
| <a name="g-socket-receive-message.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>address</p></td> |
| <td class="parameter_description"><p> a pointer to a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> |
| pointer, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter for returning results. Default is transfer full."><span class="acronym">out</span></acronym>][<acronym title="NULL may be passed as the value in, out, in-out; or as a return value."><span class="acronym">nullable</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>vectors</p></td> |
| <td class="parameter_description"><p> an array of <a class="link" href="GSocket.html#GInputVector" title="struct GInputVector"><span class="type">GInputVector</span></a> structs. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=num_vectors]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>num_vectors</p></td> |
| <td class="parameter_description"><p>the number of elements in <em class="parameter"><code>vectors</code></em> |
| , or -1</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>messages</p></td> |
| <td class="parameter_description"><p> a pointer which |
| may be filled with an array of <a href="GSocketControlMessage.html#GSocketControlMessage-struct"><span class="type">GSocketControlMessages</span></a>, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=num_messages][<acronym title="Parameter for returning results. Default is transfer full."><span class="acronym">out</span></acronym>][<acronym title="NULL may be passed as the value in, out, in-out; or as a return value."><span class="acronym">nullable</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>num_messages</p></td> |
| <td class="parameter_description"><p> a pointer which will be filled with the number of |
| elements in <em class="parameter"><code>messages</code></em> |
| , or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter for returning results. Default is transfer full."><span class="acronym">out</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>flags</p></td> |
| <td class="parameter_description"><p> a pointer to an int containing <a class="link" href="GSocket.html#GSocketMsgFlags" title="enum GSocketMsgFlags"><span class="type">GSocketMsgFlags</span></a> flags. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter for input and for returning results. Default is transfer full."><span class="acronym">inout</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>cancellable</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p>a <a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> pointer, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-receive-message.returns"></a><h4>Returns</h4> |
| <p> Number of bytes read, or 0 if the connection was closed by |
| the peer, or -1 on error</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-receive-messages"></a><h3>g_socket_receive_messages ()</h3> |
| <pre class="programlisting"><a href="../glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a> |
| g_socket_receive_messages (<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="GSocket.html#GInputMessage" title="struct GInputMessage"><span class="type">GInputMessage</span></a> *messages</code></em>, |
| <em class="parameter"><code><a href="../glib-Basic-Types.html#guint"><span class="type">guint</span></a> num_messages</code></em>, |
| <em class="parameter"><code><a href="../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="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p>Receive multiple data messages from <em class="parameter"><code>socket</code></em> |
| in one go. 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>, <a class="link" href="GSocket.html#g-socket-receive-from" title="g_socket_receive_from ()"><code class="function">g_socket_receive_from()</code></a>, 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>.</p> |
| <p><em class="parameter"><code>messages</code></em> |
| must point to an array of <a class="link" href="GSocket.html#GInputMessage" title="struct GInputMessage"><span class="type">GInputMessage</span></a> structs and |
| <em class="parameter"><code>num_messages</code></em> |
| must be the length of this array. Each <a class="link" href="GSocket.html#GInputMessage" title="struct GInputMessage"><span class="type">GInputMessage</span></a> |
| contains a pointer to an array of <a class="link" href="GSocket.html#GInputVector" title="struct GInputVector"><span class="type">GInputVector</span></a> structs describing the |
| buffers that the data received in each message will be written to. Using |
| multiple <a href="GSocket.html#GInputVector"><span class="type">GInputVectors</span></a> is more memory-efficient than manually copying data |
| out of a single buffer to multiple sources, and more system-call-efficient |
| than making multiple calls to <a class="link" href="GSocket.html#g-socket-receive" title="g_socket_receive ()"><code class="function">g_socket_receive()</code></a>, such as in scenarios where |
| a lot of data packets need to be received (e.g. high-bandwidth video |
| streaming over RTP/UDP).</p> |
| <p><em class="parameter"><code>flags</code></em> |
| modify how all messages are received. 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. These |
| flags affect the overall receive operation. Flags affecting individual |
| messages are returned in <a class="link" href="GSocket.html#GInputMessage.flags"><span class="type">GInputMessage.flags</span></a>.</p> |
| <p>The other members of <a class="link" href="GSocket.html#GInputMessage" title="struct GInputMessage"><span class="type">GInputMessage</span></a> are treated as described in its |
| documentation.</p> |
| <p>If <a class="link" href="GSocket.html#GSocket--blocking" title="The “blocking” property"><span class="type">“blocking”</span></a> is <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> the call will block until <em class="parameter"><code>num_messages</code></em> |
| have |
| been received, or the end of the stream is reached.</p> |
| <p>If <a class="link" href="GSocket.html#GSocket--blocking" title="The “blocking” property"><span class="type">“blocking”</span></a> is <a href="../glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> the call will return up to <em class="parameter"><code>num_messages</code></em> |
| |
| without blocking, or <a class="link" href="gio-GIOError.html#G-IO-ERROR-WOULD-BLOCK:CAPS"><code class="literal">G_IO_ERROR_WOULD_BLOCK</code></a> if no messages are queued in the |
| operating system to be received.</p> |
| <p>In blocking mode, if <a class="link" href="GSocket.html#GSocket--timeout" title="The “timeout” property"><span class="type">“timeout”</span></a> is positive and is reached before any |
| messages are received, <a class="link" href="gio-GIOError.html#G-IO-ERROR-TIMED-OUT:CAPS"><code class="literal">G_IO_ERROR_TIMED_OUT</code></a> is returned, otherwise up to |
| <em class="parameter"><code>num_messages</code></em> |
| are returned. (Note: This is effectively the |
| behaviour of <code class="literal">MSG_WAITFORONE</code> with <code class="function">recvmmsg()</code>.)</p> |
| <p>To be notified when messages are available, wait for the |
| <a href="../glib-IO-Channels.html#G-IO-IN:CAPS"><code class="literal">G_IO_IN</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-receive-messages" title="g_socket_receive_messages ()"><code class="function">g_socket_receive_messages()</code></a> even if you were |
| previously notified of a <a href="../glib-IO-Channels.html#G-IO-IN:CAPS"><code class="literal">G_IO_IN</code></a> condition.</p> |
| <p>If the remote peer closes the connection, any messages queued in the |
| operating system will be returned, and subsequent calls to |
| <a class="link" href="GSocket.html#g-socket-receive-messages" title="g_socket_receive_messages ()"><code class="function">g_socket_receive_messages()</code></a> will return 0 (with no error set).</p> |
| <p>On error -1 is returned and <em class="parameter"><code>error</code></em> |
| is set accordingly. An error will only |
| be returned if zero messages could be received; otherwise the number of |
| messages successfully received before the error will be returned.</p> |
| <div class="refsect3"> |
| <a name="g-socket-receive-messages.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>messages</p></td> |
| <td class="parameter_description"><p> an array of <a class="link" href="GSocket.html#GInputMessage" title="struct GInputMessage"><span class="type">GInputMessage</span></a> structs. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=num_messages]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>num_messages</p></td> |
| <td class="parameter_description"><p>the number of elements in <em class="parameter"><code>messages</code></em> |
| </p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>flags</p></td> |
| <td class="parameter_description"><p>an int containing <a class="link" href="GSocket.html#GSocketMsgFlags" title="enum GSocketMsgFlags"><span class="type">GSocketMsgFlags</span></a> flags for the overall operation</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>cancellable</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-receive-messages.returns"></a><h4>Returns</h4> |
| <p> number of messages received, or -1 on error. Note that the number |
| of messages received may be smaller than <em class="parameter"><code>num_messages</code></em> |
| if in non-blocking |
| mode, if the peer closed the connection, or if <em class="parameter"><code>num_messages</code></em> |
| was larger than <code class="literal">UIO_MAXIOV</code> (1024), in which case the caller may re-try |
| to receive the remaining messages.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-48.html#api-index-2.48">2.48</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-receive-with-blocking"></a><h3>g_socket_receive_with_blocking ()</h3> |
| <pre class="programlisting"><a href="../glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> |
| g_socket_receive_with_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="../glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *buffer</code></em>, |
| <em class="parameter"><code><a href="../glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> size</code></em>, |
| <em class="parameter"><code><a href="../glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> blocking</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="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p>This behaves exactly the same as <a class="link" href="GSocket.html#g-socket-receive" title="g_socket_receive ()"><code class="function">g_socket_receive()</code></a>, except that |
| the choice of blocking or non-blocking behavior is determined by |
| the <em class="parameter"><code>blocking</code></em> |
| argument rather than by <em class="parameter"><code>socket</code></em> |
| 's properties.</p> |
| <div class="refsect3"> |
| <a name="g-socket-receive-with-blocking.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>buffer</p></td> |
| <td class="parameter_description"><p> a buffer to |
| read data into (which should be at least <em class="parameter"><code>size</code></em> |
| bytes long). </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=size][<acronym title="Generics and defining elements of containers and arrays."><span class="acronym">element-type</span></acronym> guint8]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>size</p></td> |
| <td class="parameter_description"><p>the number of bytes you want to read from the socket</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>blocking</p></td> |
| <td class="parameter_description"><p>whether to do blocking or non-blocking I/O</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>cancellable</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-receive-with-blocking.returns"></a><h4>Returns</h4> |
| <p> Number of bytes read, or 0 if the connection was closed by |
| the peer, or -1 on error</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-26.html#api-index-2.26">2.26</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-send"></a><h3>g_socket_send ()</h3> |
| <pre class="programlisting"><a href="../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="../glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *buffer</code></em>, |
| <em class="parameter"><code><a href="../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="../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="../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="../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="../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="refsect3"> |
| <a name="g-socket-send.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>buffer</p></td> |
| <td class="parameter_description"><p> the buffer |
| containing the data to send. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=size][<acronym title="Generics and defining elements of containers and arrays."><span class="acronym">element-type</span></acronym> guint8]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>size</p></td> |
| <td class="parameter_description"><p>the number of bytes to send</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>cancellable</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-send.returns"></a><h4>Returns</h4> |
| <p> Number of bytes written (which may be less than <em class="parameter"><code>size</code></em> |
| ), or -1 |
| on error</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-send-to"></a><h3>g_socket_send_to ()</h3> |
| <pre class="programlisting"><a href="../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="../glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *buffer</code></em>, |
| <em class="parameter"><code><a href="../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="../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="../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="refsect3"> |
| <a name="g-socket-send-to.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>address</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a>, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>buffer</p></td> |
| <td class="parameter_description"><p> the buffer |
| containing the data to send. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=size][<acronym title="Generics and defining elements of containers and arrays."><span class="acronym">element-type</span></acronym> guint8]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>size</p></td> |
| <td class="parameter_description"><p>the number of bytes to send</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>cancellable</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-send-to.returns"></a><h4>Returns</h4> |
| <p> Number of bytes written (which may be less than <em class="parameter"><code>size</code></em> |
| ), or -1 |
| on error</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-send-message"></a><h3>g_socket_send_message ()</h3> |
| <pre class="programlisting"><a href="../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="struct GOutputVector"><span class="type">GOutputVector</span></a> *vectors</code></em>, |
| <em class="parameter"><code><a href="../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="../glib-Basic-Types.html#gint"><span class="type">gint</span></a> num_messages</code></em>, |
| <em class="parameter"><code><a href="../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="../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> |
| . For sending multiple messages see |
| <a class="link" href="GSocket.html#g-socket-send-messages" title="g_socket_send_messages ()"><code class="function">g_socket_send_messages()</code></a>; 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="../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="struct 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="struct GOutputVector"><span class="type">GOutputVector</span></a> with a |
| <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> buffer pointer.) The <a class="link" href="GSocket.html#GOutputVector" title="struct GOutputVector"><span class="type">GOutputVector</span></a> structs describe the buffers |
| that the sent data will be gathered from. Using multiple |
| <a href="GSocket.html#GOutputVector"><span class="type">GOutputVectors</span></a> 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="../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="../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="../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="../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="refsect3"> |
| <a name="g-socket-send-message.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>address</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a>, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>vectors</p></td> |
| <td class="parameter_description"><p> an array of <a class="link" href="GSocket.html#GOutputVector" title="struct GOutputVector"><span class="type">GOutputVector</span></a> structs. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=num_vectors]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>num_vectors</p></td> |
| <td class="parameter_description"><p>the number of elements in <em class="parameter"><code>vectors</code></em> |
| , or -1</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>messages</p></td> |
| <td class="parameter_description"><p> a pointer to an |
| array of <a href="GSocketControlMessage.html#GSocketControlMessage-struct"><span class="type">GSocketControlMessages</span></a>, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=num_messages][<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>num_messages</p></td> |
| <td class="parameter_description"><p>number of elements in <em class="parameter"><code>messages</code></em> |
| , or -1.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>flags</p></td> |
| <td class="parameter_description"><p>an int containing <a class="link" href="GSocket.html#GSocketMsgFlags" title="enum GSocketMsgFlags"><span class="type">GSocketMsgFlags</span></a> flags</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>cancellable</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-send-message.returns"></a><h4>Returns</h4> |
| <p> Number of bytes written (which may be less than <em class="parameter"><code>size</code></em> |
| ), or -1 |
| on error</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-send-messages"></a><h3>g_socket_send_messages ()</h3> |
| <pre class="programlisting"><a href="../glib-Basic-Types.html#gint"><span class="returnvalue">gint</span></a> |
| g_socket_send_messages (<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="GSocket.html#GOutputMessage" title="struct GOutputMessage"><span class="type">GOutputMessage</span></a> *messages</code></em>, |
| <em class="parameter"><code><a href="../glib-Basic-Types.html#guint"><span class="type">guint</span></a> num_messages</code></em>, |
| <em class="parameter"><code><a href="../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="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p>Send multiple data messages from <em class="parameter"><code>socket</code></em> |
| in one go. 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>, <a class="link" href="GSocket.html#g-socket-send-to" title="g_socket_send_to ()"><code class="function">g_socket_send_to()</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>.</p> |
| <p><em class="parameter"><code>messages</code></em> |
| must point to an array of <a class="link" href="GSocket.html#GOutputMessage" title="struct GOutputMessage"><span class="type">GOutputMessage</span></a> structs and |
| <em class="parameter"><code>num_messages</code></em> |
| must be the length of this array. Each <a class="link" href="GSocket.html#GOutputMessage" title="struct GOutputMessage"><span class="type">GOutputMessage</span></a> |
| contains an address to send the data to, and a pointer to an array of |
| <a class="link" href="GSocket.html#GOutputVector" title="struct GOutputVector"><span class="type">GOutputVector</span></a> structs to describe the buffers that the data to be sent |
| for each message will be gathered from. Using multiple <a href="GSocket.html#GOutputVector"><span class="type">GOutputVectors</span></a> 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>. Sending multiple messages in one go avoids the |
| overhead of making a lot of syscalls in scenarios where a lot of data |
| packets need to be sent (e.g. high-bandwidth video streaming over RTP/UDP), |
| or where the same data needs to be sent to multiple recipients.</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 all 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 if no data was written at all, otherwise the number of |
| messages sent will be returned. To be notified when space is available, |
| wait for the <a href="../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="../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. An error will only |
| be returned if zero messages could be sent; otherwise the number of messages |
| successfully sent before the error will be returned.</p> |
| <div class="refsect3"> |
| <a name="g-socket-send-messages.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>messages</p></td> |
| <td class="parameter_description"><p> an array of <a class="link" href="GSocket.html#GOutputMessage" title="struct GOutputMessage"><span class="type">GOutputMessage</span></a> structs. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=num_messages]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>num_messages</p></td> |
| <td class="parameter_description"><p>the number of elements in <em class="parameter"><code>messages</code></em> |
| </p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>flags</p></td> |
| <td class="parameter_description"><p>an int containing <a class="link" href="GSocket.html#GSocketMsgFlags" title="enum GSocketMsgFlags"><span class="type">GSocketMsgFlags</span></a> flags</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>cancellable</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-send-messages.returns"></a><h4>Returns</h4> |
| <p> number of messages sent, or -1 on error. Note that the number of |
| messages sent may be smaller than <em class="parameter"><code>num_messages</code></em> |
| if the socket is |
| non-blocking or if <em class="parameter"><code>num_messages</code></em> |
| was larger than UIO_MAXIOV (1024), |
| in which case the caller may re-try to send the remaining messages.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-44.html#api-index-2.44">2.44</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-send-with-blocking"></a><h3>g_socket_send_with_blocking ()</h3> |
| <pre class="programlisting"><a href="../glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> |
| g_socket_send_with_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>const <a href="../glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *buffer</code></em>, |
| <em class="parameter"><code><a href="../glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> size</code></em>, |
| <em class="parameter"><code><a href="../glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> blocking</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="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p>This behaves exactly the same as <a class="link" href="GSocket.html#g-socket-send" title="g_socket_send ()"><code class="function">g_socket_send()</code></a>, except that |
| the choice of blocking or non-blocking behavior is determined by |
| the <em class="parameter"><code>blocking</code></em> |
| argument rather than by <em class="parameter"><code>socket</code></em> |
| 's properties.</p> |
| <div class="refsect3"> |
| <a name="g-socket-send-with-blocking.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>buffer</p></td> |
| <td class="parameter_description"><p> the buffer |
| containing the data to send. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=size][<acronym title="Generics and defining elements of containers and arrays."><span class="acronym">element-type</span></acronym> guint8]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>size</p></td> |
| <td class="parameter_description"><p>the number of bytes to send</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>blocking</p></td> |
| <td class="parameter_description"><p>whether to do blocking or non-blocking I/O</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>cancellable</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-send-with-blocking.returns"></a><h4>Returns</h4> |
| <p> Number of bytes written (which may be less than <em class="parameter"><code>size</code></em> |
| ), or -1 |
| on error</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-26.html#api-index-2.26">2.26</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-close"></a><h3>g_socket_close ()</h3> |
| <pre class="programlisting"><a href="../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="../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="../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="GTcpConnection.html" title="GTcpConnection"><span class="type">GTcpConnection</span></a> does if you call |
| <a class="link" href="GTcpConnection.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="refsect3"> |
| <a name="g-socket-close.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-close.returns"></a><h4>Returns</h4> |
| <p> <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a href="../glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> on error</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-is-closed"></a><h3>g_socket_is_closed ()</h3> |
| <pre class="programlisting"><a href="../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="refsect3"> |
| <a name="g-socket-is-closed.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-is-closed.returns"></a><h4>Returns</h4> |
| <p> <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if socket is closed, <a href="../glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-shutdown"></a><h3>g_socket_shutdown ()</h3> |
| <pre class="programlisting"><a href="../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="../glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> shutdown_read</code></em>, |
| <em class="parameter"><code><a href="../glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> shutdown_write</code></em>, |
| <em class="parameter"><code><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p>Shut down part or all of a full-duplex connection.</p> |
| <p>If <em class="parameter"><code>shutdown_read</code></em> |
| is <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> then the receiving 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="../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="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>.</p> |
| <p>One example where it is useful to shut down only one side of a connection 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="refsect3"> |
| <a name="g-socket-shutdown.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>shutdown_read</p></td> |
| <td class="parameter_description"><p>whether to shut down the read side</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>shutdown_write</p></td> |
| <td class="parameter_description"><p>whether to shut down the write side</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-shutdown.returns"></a><h4>Returns</h4> |
| <p> <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a href="../glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> on error</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-is-connected"></a><h3>g_socket_is_connected ()</h3> |
| <pre class="programlisting"><a href="../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> |
| <p>If using <a class="link" href="GSocket.html#g-socket-shutdown" title="g_socket_shutdown ()"><code class="function">g_socket_shutdown()</code></a>, this function will return <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> until the |
| socket has been shut down for reading and writing. If you do a non-blocking |
| connect, this function will not return <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> until after you call |
| <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="refsect3"> |
| <a name="g-socket-is-connected.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-is-connected.returns"></a><h4>Returns</h4> |
| <p> <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if socket is connected, <a href="../glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-create-source"></a><h3>g_socket_create_source ()</h3> |
| <pre class="programlisting"><a href="../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="../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="../glib-The-Main-Event-Loop.html#GSource"><span class="type">GSource</span></a> that can be attached to a <a href="../glib-The-Main-Event-Loop.html#GMainContext"><code class="literal">GMainContext</code></a> to monitor |
| for the availability of the specified <em class="parameter"><code>condition</code></em> |
| on the socket. The <a href="../glib-The-Main-Event-Loop.html#GSource"><span class="type">GSource</span></a> |
| keeps a reference to the <em class="parameter"><code>socket</code></em> |
| .</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="../glib-IO-Channels.html#G-IO-ERR:CAPS"><code class="literal">G_IO_ERR</code></a> or <a href="../glib-IO-Channels.html#G-IO-HUP:CAPS"><code class="literal">G_IO_HUP</code></a> in <em class="parameter"><code>condition</code></em> |
| ; |
| these conditions will always be reported output if they are true.</p> |
| <p><em class="parameter"><code>cancellable</code></em> |
| if not <a href="../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> |
| <p>If <em class="parameter"><code>socket</code></em> |
| has a timeout set, and it is reached before <em class="parameter"><code>condition</code></em> |
| |
| occurs, the source will then trigger anyway, reporting <a href="../glib-IO-Channels.html#G-IO-IN:CAPS"><code class="literal">G_IO_IN</code></a> or |
| <a href="../glib-IO-Channels.html#G-IO-OUT:CAPS"><code class="literal">G_IO_OUT</code></a> depending on <em class="parameter"><code>condition</code></em> |
| . However, <em class="parameter"><code>socket</code></em> |
| will have been |
| marked as having had a timeout, and so the next <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> I/O method |
| you call will then fail with a <a class="link" href="gio-GIOError.html#G-IO-ERROR-TIMED-OUT:CAPS"><code class="literal">G_IO_ERROR_TIMED_OUT</code></a>.</p> |
| <p><span class="annotation">[<acronym title="Exposed in C code, not necessarily available in other languages."><span class="acronym">skip</span></acronym>]</span></p> |
| <div class="refsect3"> |
| <a name="g-socket-create-source.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>condition</p></td> |
| <td class="parameter_description"><p>a <a href="../glib-IO-Channels.html#GIOCondition"><span class="type">GIOCondition</span></a> mask to monitor</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>cancellable</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="GCancellable.html" title="GCancellable"><code class="literal">GCancellable</code></a> or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-create-source.returns"></a><h4>Returns</h4> |
| <p> a newly allocated <a href="../glib-The-Main-Event-Loop.html#GSource"><code class="literal">GSource</code></a>, free with <a href="../glib-The-Main-Event-Loop.html#g-source-unref"><code class="function">g_source_unref()</code></a>. </p> |
| <p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-condition-check"></a><h3>g_socket_condition_check ()</h3> |
| <pre class="programlisting"><a href="../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="../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>Note that on Windows, it is possible for an operation to return |
| <a class="link" href="gio-GIOError.html#G-IO-ERROR-WOULD-BLOCK:CAPS"><code class="literal">G_IO_ERROR_WOULD_BLOCK</code></a> even immediately after |
| <a class="link" href="GSocket.html#g-socket-condition-check" title="g_socket_condition_check ()"><code class="function">g_socket_condition_check()</code></a> has claimed that the socket is ready for |
| writing. Rather than calling <a class="link" href="GSocket.html#g-socket-condition-check" title="g_socket_condition_check ()"><code class="function">g_socket_condition_check()</code></a> and then |
| writing to the socket if it succeeds, it is generally better to |
| simply try writing to the socket right away, and try again later if |
| the initial attempt 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>It is meaningless to specify <a href="../glib-IO-Channels.html#G-IO-ERR:CAPS"><code class="literal">G_IO_ERR</code></a> or <a href="../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="refsect3"> |
| <a name="g-socket-condition-check.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>condition</p></td> |
| <td class="parameter_description"><p>a <a href="../glib-IO-Channels.html#GIOCondition"><span class="type">GIOCondition</span></a> mask to check</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-condition-check.returns"></a><h4>Returns</h4> |
| <p> the <em class="parameter"><code>GIOCondition</code></em> |
| mask of the current state</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-condition-wait"></a><h3>g_socket_condition_wait ()</h3> |
| <pre class="programlisting"><a href="../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="../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="../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="../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, or if the |
| socket has a timeout set and it is reached before the condition is |
| met, then <a href="../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="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, is set to |
| the appropriate value (<a class="link" href="gio-GIOError.html#G-IO-ERROR-CANCELLED:CAPS"><code class="literal">G_IO_ERROR_CANCELLED</code></a> or |
| <a class="link" href="gio-GIOError.html#G-IO-ERROR-TIMED-OUT:CAPS"><code class="literal">G_IO_ERROR_TIMED_OUT</code></a>).</p> |
| <p>See also <a class="link" href="GSocket.html#g-socket-condition-timed-wait" title="g_socket_condition_timed_wait ()"><code class="function">g_socket_condition_timed_wait()</code></a>.</p> |
| <div class="refsect3"> |
| <a name="g-socket-condition-wait.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>condition</p></td> |
| <td class="parameter_description"><p>a <a href="../glib-IO-Channels.html#GIOCondition"><span class="type">GIOCondition</span></a> mask to wait for</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>cancellable</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a>, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p>a <a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> pointer, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-condition-wait.returns"></a><h4>Returns</h4> |
| <p> <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the condition was met, <a href="../glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-condition-timed-wait"></a><h3>g_socket_condition_timed_wait ()</h3> |
| <pre class="programlisting"><a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| g_socket_condition_timed_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="../glib-IO-Channels.html#GIOCondition"><span class="type">GIOCondition</span></a> condition</code></em>, |
| <em class="parameter"><code><a href="../glib-Basic-Types.html#gint64"><span class="type">gint64</span></a> timeout</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="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p>Waits for up to <em class="parameter"><code>timeout</code></em> |
| microseconds for <em class="parameter"><code>condition</code></em> |
| to become true |
| on <em class="parameter"><code>socket</code></em> |
| . If the condition is met, <a href="../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, or if |
| <em class="parameter"><code>timeout</code></em> |
| (or the socket's <a class="link" href="GSocket.html#GSocket--timeout" title="The “timeout” property"><span class="type">“timeout”</span></a>) is reached before the |
| condition is met, then <a href="../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="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, |
| is set to the appropriate value (<a class="link" href="gio-GIOError.html#G-IO-ERROR-CANCELLED:CAPS"><code class="literal">G_IO_ERROR_CANCELLED</code></a> or |
| <a class="link" href="gio-GIOError.html#G-IO-ERROR-TIMED-OUT:CAPS"><code class="literal">G_IO_ERROR_TIMED_OUT</code></a>).</p> |
| <p>If you don't want a timeout, use <a class="link" href="GSocket.html#g-socket-condition-wait" title="g_socket_condition_wait ()"><code class="function">g_socket_condition_wait()</code></a>. |
| (Alternatively, you can pass -1 for <em class="parameter"><code>timeout</code></em> |
| .)</p> |
| <p>Note that although <em class="parameter"><code>timeout</code></em> |
| is in microseconds for consistency with |
| other GLib APIs, this function actually only has millisecond |
| resolution, and the behavior is undefined if <em class="parameter"><code>timeout</code></em> |
| is not an |
| exact number of milliseconds.</p> |
| <div class="refsect3"> |
| <a name="g-socket-condition-timed-wait.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>condition</p></td> |
| <td class="parameter_description"><p>a <a href="../glib-IO-Channels.html#GIOCondition"><span class="type">GIOCondition</span></a> mask to wait for</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>timeout</p></td> |
| <td class="parameter_description"><p>the maximum time (in microseconds) to wait, or -1</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>cancellable</p></td> |
| <td class="parameter_description"><p> a <a class="link" href="GCancellable.html" title="GCancellable"><span class="type">GCancellable</span></a>, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p>a <a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> pointer, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-condition-timed-wait.returns"></a><h4>Returns</h4> |
| <p> <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the condition was met, <a href="../glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-32.html#api-index-2.32">2.32</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-get-available-bytes"></a><h3>g_socket_get_available_bytes ()</h3> |
| <pre class="programlisting"><a href="../glib-Basic-Types.html#gssize"><span class="returnvalue">gssize</span></a> |
| g_socket_get_available_bytes (<em class="parameter"><code><a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> *socket</code></em>);</pre> |
| <p>Get the amount of data pending in the OS input buffer, without blocking.</p> |
| <p>If <em class="parameter"><code>socket</code></em> |
| is a UDP or SCTP socket, this will return the size of |
| just the next packet, even if additional packets are buffered after |
| that one.</p> |
| <p>Note that on Windows, this function is rather inefficient in the |
| UDP case, and so if you know any plausible upper bound on the size |
| of the incoming packet, it is better to just do a |
| <a class="link" href="GSocket.html#g-socket-receive" title="g_socket_receive ()"><code class="function">g_socket_receive()</code></a> with a buffer of that size, rather than calling |
| <a class="link" href="GSocket.html#g-socket-get-available-bytes" title="g_socket_get_available_bytes ()"><code class="function">g_socket_get_available_bytes()</code></a> first and then doing a receive of |
| exactly the right size.</p> |
| <div class="refsect3"> |
| <a name="g-socket-get-available-bytes.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-get-available-bytes.returns"></a><h4>Returns</h4> |
| <p> the number of bytes that can be read from the socket |
| without blocking or truncating, or -1 on error.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-32.html#api-index-2.32">2.32</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <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="../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="refsect3"> |
| <a name="g-socket-set-listen-backlog.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>backlog</p></td> |
| <td class="parameter_description"><p>the maximum number of pending connections.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-get-listen-backlog"></a><h3>g_socket_get_listen_backlog ()</h3> |
| <pre class="programlisting"><a href="../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="refsect3"> |
| <a name="g-socket-get-listen-backlog.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-get-listen-backlog.returns"></a><h4>Returns</h4> |
| <p> the maximum number of pending connections.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-get-blocking"></a><h3>g_socket_get_blocking ()</h3> |
| <pre class="programlisting"><a href="../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="refsect3"> |
| <a name="g-socket-get-blocking.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-get-blocking.returns"></a><h4>Returns</h4> |
| <p> <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if blocking I/O is used, <a href="../glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <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="../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 (which don’t take an explicit blocking parameter) 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="refsect3"> |
| <a name="g-socket-set-blocking.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>blocking</p></td> |
| <td class="parameter_description"><p>Whether to use blocking I/O or not.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-get-keepalive"></a><h3>g_socket_get_keepalive ()</h3> |
| <pre class="programlisting"><a href="../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="refsect3"> |
| <a name="g-socket-get-keepalive.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-get-keepalive.returns"></a><h4>Returns</h4> |
| <p> <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if keepalive is active, <a href="../glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> otherwise.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <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="../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="refsect3"> |
| <a name="g-socket-set-keepalive.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>keepalive</p></td> |
| <td class="parameter_description"><p>Value for the keepalive flag</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-get-timeout"></a><h3>g_socket_get_timeout ()</h3> |
| <pre class="programlisting"><a href="../glib-Basic-Types.html#guint"><span class="returnvalue">guint</span></a> |
| g_socket_get_timeout (<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 timeout setting of the socket. For details on this, see |
| <a class="link" href="GSocket.html#g-socket-set-timeout" title="g_socket_set_timeout ()"><code class="function">g_socket_set_timeout()</code></a>.</p> |
| <div class="refsect3"> |
| <a name="g-socket-get-timeout.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-get-timeout.returns"></a><h4>Returns</h4> |
| <p> the timeout in seconds</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-26.html#api-index-2.26">2.26</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-set-timeout"></a><h3>g_socket_set_timeout ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_socket_set_timeout (<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="../glib-Basic-Types.html#guint"><span class="type">guint</span></a> timeout</code></em>);</pre> |
| <p>Sets the time in seconds after which I/O operations on <em class="parameter"><code>socket</code></em> |
| will |
| time out if they have not yet completed.</p> |
| <p>On a blocking socket, this means that any blocking <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a> |
| operation will time out after <em class="parameter"><code>timeout</code></em> |
| seconds of inactivity, |
| returning <a class="link" href="gio-GIOError.html#G-IO-ERROR-TIMED-OUT:CAPS"><code class="literal">G_IO_ERROR_TIMED_OUT</code></a>.</p> |
| <p>On a non-blocking socket, calls to <a class="link" href="GSocket.html#g-socket-condition-wait" title="g_socket_condition_wait ()"><code class="function">g_socket_condition_wait()</code></a> will |
| also fail with <a class="link" href="gio-GIOError.html#G-IO-ERROR-TIMED-OUT:CAPS"><code class="literal">G_IO_ERROR_TIMED_OUT</code></a> after the given time. Sources |
| created with <a class="link" href="GSocket.html#g-socket-create-source" title="g_socket_create_source ()"><code class="function">g_socket_create_source()</code></a> will trigger after |
| <em class="parameter"><code>timeout</code></em> |
| seconds of inactivity, with the requested condition |
| set, at which point calling <a class="link" href="GSocket.html#g-socket-receive" title="g_socket_receive ()"><code class="function">g_socket_receive()</code></a>, <a class="link" href="GSocket.html#g-socket-send" title="g_socket_send ()"><code class="function">g_socket_send()</code></a>, |
| <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>, etc, will fail with |
| <a class="link" href="gio-GIOError.html#G-IO-ERROR-TIMED-OUT:CAPS"><code class="literal">G_IO_ERROR_TIMED_OUT</code></a>.</p> |
| <p>If <em class="parameter"><code>timeout</code></em> |
| is 0 (the default), operations will never time out |
| on their own.</p> |
| <p>Note that if an I/O operation is interrupted by a signal, this may |
| cause the timeout to be reset.</p> |
| <div class="refsect3"> |
| <a name="g-socket-set-timeout.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>timeout</p></td> |
| <td class="parameter_description"><p>the timeout for <em class="parameter"><code>socket</code></em> |
| , in seconds, or 0 for none</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-26.html#api-index-2.26">2.26</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-set-ttl"></a><h3>g_socket_set_ttl ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_socket_set_ttl (<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="../glib-Basic-Types.html#guint"><span class="type">guint</span></a> ttl</code></em>);</pre> |
| <p>Sets the time-to-live for outgoing unicast packets on <em class="parameter"><code>socket</code></em> |
| . |
| By default the platform-specific default value is used.</p> |
| <div class="refsect3"> |
| <a name="g-socket-set-ttl.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>ttl</p></td> |
| <td class="parameter_description"><p>the time-to-live value for all unicast packets on <em class="parameter"><code>socket</code></em> |
| </p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-32.html#api-index-2.32">2.32</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-get-ttl"></a><h3>g_socket_get_ttl ()</h3> |
| <pre class="programlisting"><a href="../glib-Basic-Types.html#guint"><span class="returnvalue">guint</span></a> |
| g_socket_get_ttl (<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 unicast time-to-live setting on <em class="parameter"><code>socket</code></em> |
| ; see |
| <a class="link" href="GSocket.html#g-socket-set-ttl" title="g_socket_set_ttl ()"><code class="function">g_socket_set_ttl()</code></a> for more details.</p> |
| <div class="refsect3"> |
| <a name="g-socket-get-ttl.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-get-ttl.returns"></a><h4>Returns</h4> |
| <p> the time-to-live setting on <em class="parameter"><code>socket</code></em> |
| </p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-32.html#api-index-2.32">2.32</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-get-broadcast"></a><h3>g_socket_get_broadcast ()</h3> |
| <pre class="programlisting"><a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| g_socket_get_broadcast (<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 broadcast setting on <em class="parameter"><code>socket</code></em> |
| ; if <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>, |
| it is possible to send packets to broadcast |
| addresses.</p> |
| <div class="refsect3"> |
| <a name="g-socket-get-broadcast.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-get-broadcast.returns"></a><h4>Returns</h4> |
| <p> the broadcast setting on <em class="parameter"><code>socket</code></em> |
| </p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-32.html#api-index-2.32">2.32</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-set-broadcast"></a><h3>g_socket_set_broadcast ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_socket_set_broadcast (<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="../glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> broadcast</code></em>);</pre> |
| <p>Sets whether <em class="parameter"><code>socket</code></em> |
| should allow sending to broadcast addresses. |
| This is <a href="../glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> by default.</p> |
| <div class="refsect3"> |
| <a name="g-socket-set-broadcast.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>broadcast</p></td> |
| <td class="parameter_description"><p>whether <em class="parameter"><code>socket</code></em> |
| should allow sending to broadcast |
| addresses</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-32.html#api-index-2.32">2.32</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-get-option"></a><h3>g_socket_get_option ()</h3> |
| <pre class="programlisting"><a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| g_socket_get_option (<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="../glib-Basic-Types.html#gint"><span class="type">gint</span></a> level</code></em>, |
| <em class="parameter"><code><a href="../glib-Basic-Types.html#gint"><span class="type">gint</span></a> optname</code></em>, |
| <em class="parameter"><code><a href="../glib-Basic-Types.html#gint"><span class="type">gint</span></a> *value</code></em>, |
| <em class="parameter"><code><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p>Gets the value of an integer-valued option on <em class="parameter"><code>socket</code></em> |
| , as with |
| <code class="function">getsockopt()</code>. (If you need to fetch a non-integer-valued option, |
| you will need to call <code class="function">getsockopt()</code> directly.)</p> |
| <p>The <a class="link" href="gio-gnetworking.h.html" title="gnetworking.h"><gio/gnetworking.h></a> |
| header pulls in system headers that will define most of the |
| standard/portable socket options. For unusual socket protocols or |
| platform-dependent options, you may need to include additional |
| headers.</p> |
| <p>Note that even for socket options that are a single byte in size, |
| <em class="parameter"><code>value</code></em> |
| is still a pointer to a <a href="../glib-Basic-Types.html#gint"><span class="type">gint</span></a> variable, not a <a href="../glib-Basic-Types.html#guchar"><span class="type">guchar</span></a>; |
| <a class="link" href="GSocket.html#g-socket-get-option" title="g_socket_get_option ()"><code class="function">g_socket_get_option()</code></a> will handle the conversion internally.</p> |
| <div class="refsect3"> |
| <a name="g-socket-get-option.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>level</p></td> |
| <td class="parameter_description"><p>the "API level" of the option (eg, <code class="literal">SOL_SOCKET</code>)</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>optname</p></td> |
| <td class="parameter_description"><p>the "name" of the option (eg, <code class="literal">SO_BROADCAST</code>)</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>value</p></td> |
| <td class="parameter_description"><p> return location for the option value. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="Parameter for returning results. Default is transfer full."><span class="acronym">out</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-get-option.returns"></a><h4>Returns</h4> |
| <p> success or failure. On failure, <em class="parameter"><code>error</code></em> |
| will be set, and |
| the system error value (<code class="literal">errno</code> or <code class="function">WSAGetLastError()</code>) will still |
| be set to the result of the <code class="function">getsockopt()</code> call.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-36.html#api-index-2.36">2.36</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-set-option"></a><h3>g_socket_set_option ()</h3> |
| <pre class="programlisting"><a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| g_socket_set_option (<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="../glib-Basic-Types.html#gint"><span class="type">gint</span></a> level</code></em>, |
| <em class="parameter"><code><a href="../glib-Basic-Types.html#gint"><span class="type">gint</span></a> optname</code></em>, |
| <em class="parameter"><code><a href="../glib-Basic-Types.html#gint"><span class="type">gint</span></a> value</code></em>, |
| <em class="parameter"><code><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p>Sets the value of an integer-valued option on <em class="parameter"><code>socket</code></em> |
| , as with |
| <code class="function">setsockopt()</code>. (If you need to set a non-integer-valued option, |
| you will need to call <code class="function">setsockopt()</code> directly.)</p> |
| <p>The <a class="link" href="gio-gnetworking.h.html" title="gnetworking.h"><gio/gnetworking.h></a> |
| header pulls in system headers that will define most of the |
| standard/portable socket options. For unusual socket protocols or |
| platform-dependent options, you may need to include additional |
| headers.</p> |
| <div class="refsect3"> |
| <a name="g-socket-set-option.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>level</p></td> |
| <td class="parameter_description"><p>the "API level" of the option (eg, <code class="literal">SOL_SOCKET</code>)</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>optname</p></td> |
| <td class="parameter_description"><p>the "name" of the option (eg, <code class="literal">SO_BROADCAST</code>)</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>value</p></td> |
| <td class="parameter_description"><p>the value to set the option to</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-set-option.returns"></a><h4>Returns</h4> |
| <p> success or failure. On failure, <em class="parameter"><code>error</code></em> |
| will be set, and |
| the system error value (<code class="literal">errno</code> or <code class="function">WSAGetLastError()</code>) will still |
| be set to the result of the <code class="function">setsockopt()</code> call.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-36.html#api-index-2.36">2.36</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <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="refsect3"> |
| <a name="g-socket-get-family.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-get-family.returns"></a><h4>Returns</h4> |
| <p> a <a class="link" href="GSocketAddress.html#GSocketFamily" title="enum GSocketFamily"><span class="type">GSocketFamily</span></a></p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <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="refsect3"> |
| <a name="g-socket-get-fd.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-get-fd.returns"></a><h4>Returns</h4> |
| <p> the file descriptor of the socket.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <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="../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="refsect3"> |
| <a name="g-socket-get-local-address.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-get-local-address.returns"></a><h4>Returns</h4> |
| <p> a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on error. |
| Free the returned object with <a href="../gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a>. </p> |
| <p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <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="refsect3"> |
| <a name="g-socket-get-protocol.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-get-protocol.returns"></a><h4>Returns</h4> |
| <p> a protocol id, or -1 if unknown</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <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="../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="refsect3"> |
| <a name="g-socket-get-remote-address.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-get-remote-address.returns"></a><h4>Returns</h4> |
| <p> a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on error. |
| Free the returned object with <a href="../gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a>. </p> |
| <p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <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="refsect3"> |
| <a name="g-socket-get-socket-type.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-get-socket-type.returns"></a><h4>Returns</h4> |
| <p> a <a class="link" href="GSocket.html#GSocketType" title="enum GSocketType"><span class="type">GSocketType</span></a></p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-speaks-ipv4"></a><h3>g_socket_speaks_ipv4 ()</h3> |
| <pre class="programlisting"><a href="../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="refsect3"> |
| <a name="g-socket-speaks-ipv4.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a></p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-speaks-ipv4.returns"></a><h4>Returns</h4> |
| <p> <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if this socket can be used with IPv4.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-get-credentials"></a><h3>g_socket_get_credentials ()</h3> |
| <pre class="programlisting"><a class="link" href="GCredentials.html" title="GCredentials"><span class="returnvalue">GCredentials</span></a> * |
| g_socket_get_credentials (<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="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p>Returns the credentials of the foreign process connected to this |
| socket, if any (e.g. it is only supported for <a class="link" href="GSocketAddress.html#G-SOCKET-FAMILY-UNIX:CAPS"><code class="literal">G_SOCKET_FAMILY_UNIX</code></a> |
| sockets).</p> |
| <p>If this operation isn't supported on the OS, the method fails with |
| the <a class="link" href="gio-GIOError.html#G-IO-ERROR-NOT-SUPPORTED:CAPS"><code class="literal">G_IO_ERROR_NOT_SUPPORTED</code></a> error. On Linux this is implemented |
| by reading the <code class="literal">SO_PEERCRED</code> option on the underlying socket.</p> |
| <p>Other ways to obtain credentials from a foreign peer includes the |
| <a class="link" href="GUnixCredentialsMessage.html" title="GUnixCredentialsMessage"><span class="type">GUnixCredentialsMessage</span></a> type and |
| <a class="link" href="GUnixConnection.html#g-unix-connection-send-credentials" title="g_unix_connection_send_credentials ()"><code class="function">g_unix_connection_send_credentials()</code></a> / |
| <a class="link" href="GUnixConnection.html#g-unix-connection-receive-credentials" title="g_unix_connection_receive_credentials ()"><code class="function">g_unix_connection_receive_credentials()</code></a> functions.</p> |
| <div class="refsect3"> |
| <a name="g-socket-get-credentials.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-get-credentials.returns"></a><h4>Returns</h4> |
| <p> <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if <em class="parameter"><code>error</code></em> |
| is set, otherwise a <a class="link" href="GCredentials.html" title="GCredentials"><span class="type">GCredentials</span></a> object |
| that must be freed with <a href="../gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a>. </p> |
| <p><span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-26.html#api-index-2.26">2.26</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-join-multicast-group"></a><h3>g_socket_join_multicast_group ()</h3> |
| <pre class="programlisting"><a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| g_socket_join_multicast_group (<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="GInetAddress.html" title="GInetAddress"><span class="type">GInetAddress</span></a> *group</code></em>, |
| <em class="parameter"><code><a href="../glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> source_specific</code></em>, |
| <em class="parameter"><code>const <a href="../glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *iface</code></em>, |
| <em class="parameter"><code><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p>Registers <em class="parameter"><code>socket</code></em> |
| to receive multicast messages sent to <em class="parameter"><code>group</code></em> |
| . |
| <em class="parameter"><code>socket</code></em> |
| must be a <a class="link" href="GSocket.html#G-SOCKET-TYPE-DATAGRAM:CAPS"><code class="literal">G_SOCKET_TYPE_DATAGRAM</code></a> socket, and must have |
| been bound to an appropriate interface and port with |
| <a class="link" href="GSocket.html#g-socket-bind" title="g_socket_bind ()"><code class="function">g_socket_bind()</code></a>.</p> |
| <p>If <em class="parameter"><code>iface</code></em> |
| is <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, the system will automatically pick an interface |
| to bind to based on <em class="parameter"><code>group</code></em> |
| .</p> |
| <p>If <em class="parameter"><code>source_specific</code></em> |
| is <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>, source-specific multicast as defined |
| in RFC 4604 is used. Note that on older platforms this may fail |
| with a <a class="link" href="gio-GIOError.html#G-IO-ERROR-NOT-SUPPORTED:CAPS"><code class="literal">G_IO_ERROR_NOT_SUPPORTED</code></a> error.</p> |
| <div class="refsect3"> |
| <a name="g-socket-join-multicast-group.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>group</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GInetAddress.html" title="GInetAddress"><span class="type">GInetAddress</span></a> specifying the group address to join.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>iface</p></td> |
| <td class="parameter_description"><p> Name of the interface to use, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>source_specific</p></td> |
| <td class="parameter_description"><p><a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if source-specific multicast should be used</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-join-multicast-group.returns"></a><h4>Returns</h4> |
| <p> <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a href="../glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> on error.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-32.html#api-index-2.32">2.32</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-leave-multicast-group"></a><h3>g_socket_leave_multicast_group ()</h3> |
| <pre class="programlisting"><a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| g_socket_leave_multicast_group (<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="GInetAddress.html" title="GInetAddress"><span class="type">GInetAddress</span></a> *group</code></em>, |
| <em class="parameter"><code><a href="../glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> source_specific</code></em>, |
| <em class="parameter"><code>const <a href="../glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *iface</code></em>, |
| <em class="parameter"><code><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre> |
| <p>Removes <em class="parameter"><code>socket</code></em> |
| from the multicast group defined by <em class="parameter"><code>group</code></em> |
| , <em class="parameter"><code>iface</code></em> |
| , |
| and <em class="parameter"><code>source_specific</code></em> |
| (which must all have the same values they had |
| when you joined the group).</p> |
| <p><em class="parameter"><code>socket</code></em> |
| remains bound to its address and port, and can still receive |
| unicast messages after calling this.</p> |
| <div class="refsect3"> |
| <a name="g-socket-leave-multicast-group.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>group</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GInetAddress.html" title="GInetAddress"><span class="type">GInetAddress</span></a> specifying the group address to leave.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>iface</p></td> |
| <td class="parameter_description"><p> Interface used. </p></td> |
| <td class="parameter_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>source_specific</p></td> |
| <td class="parameter_description"><p><a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if source-specific multicast was used</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>error</p></td> |
| <td class="parameter_description"><p><a href="../glib-Error-Reporting.html#GError"><span class="type">GError</span></a> for error reporting, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-leave-multicast-group.returns"></a><h4>Returns</h4> |
| <p> <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> on success, <a href="../glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> on error.</p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-32.html#api-index-2.32">2.32</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-get-multicast-loopback"></a><h3>g_socket_get_multicast_loopback ()</h3> |
| <pre class="programlisting"><a href="../glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> |
| g_socket_get_multicast_loopback (<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 multicast loopback setting on <em class="parameter"><code>socket</code></em> |
| ; if <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> (the |
| default), outgoing multicast packets will be looped back to |
| multicast listeners on the same host.</p> |
| <div class="refsect3"> |
| <a name="g-socket-get-multicast-loopback.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-get-multicast-loopback.returns"></a><h4>Returns</h4> |
| <p> the multicast loopback setting on <em class="parameter"><code>socket</code></em> |
| </p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-32.html#api-index-2.32">2.32</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-set-multicast-loopback"></a><h3>g_socket_set_multicast_loopback ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_socket_set_multicast_loopback (<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="../glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a> loopback</code></em>);</pre> |
| <p>Sets whether outgoing multicast packets will be received by sockets |
| listening on that multicast address on the same host. This is <a href="../glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> |
| by default.</p> |
| <div class="refsect3"> |
| <a name="g-socket-set-multicast-loopback.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>loopback</p></td> |
| <td class="parameter_description"><p>whether <em class="parameter"><code>socket</code></em> |
| should receive messages sent to its |
| multicast groups from the local host</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-32.html#api-index-2.32">2.32</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-get-multicast-ttl"></a><h3>g_socket_get_multicast_ttl ()</h3> |
| <pre class="programlisting"><a href="../glib-Basic-Types.html#guint"><span class="returnvalue">guint</span></a> |
| g_socket_get_multicast_ttl (<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 multicast time-to-live setting on <em class="parameter"><code>socket</code></em> |
| ; see |
| <a class="link" href="GSocket.html#g-socket-set-multicast-ttl" title="g_socket_set_multicast_ttl ()"><code class="function">g_socket_set_multicast_ttl()</code></a> for more details.</p> |
| <div class="refsect3"> |
| <a name="g-socket-get-multicast-ttl.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody><tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <div class="refsect3"> |
| <a name="g-socket-get-multicast-ttl.returns"></a><h4>Returns</h4> |
| <p> the multicast time-to-live setting on <em class="parameter"><code>socket</code></em> |
| </p> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-32.html#api-index-2.32">2.32</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="g-socket-set-multicast-ttl"></a><h3>g_socket_set_multicast_ttl ()</h3> |
| <pre class="programlisting"><span class="returnvalue">void</span> |
| g_socket_set_multicast_ttl (<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="../glib-Basic-Types.html#guint"><span class="type">guint</span></a> ttl</code></em>);</pre> |
| <p>Sets the time-to-live for outgoing multicast datagrams on <em class="parameter"><code>socket</code></em> |
| . |
| By default, this is 1, meaning that multicast packets will not leave |
| the local network.</p> |
| <div class="refsect3"> |
| <a name="g-socket-set-multicast-ttl.parameters"></a><h4>Parameters</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="150px" class="parameters_name"> |
| <col class="parameters_description"> |
| <col width="200px" class="parameters_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="parameter_name"><p>socket</p></td> |
| <td class="parameter_description"><p>a <a class="link" href="GSocket.html" title="GSocket"><span class="type">GSocket</span></a>.</p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="parameter_name"><p>ttl</p></td> |
| <td class="parameter_description"><p>the time-to-live value for all multicast datagrams on <em class="parameter"><code>socket</code></em> |
| </p></td> |
| <td class="parameter_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-32.html#api-index-2.32">2.32</a></p> |
| </div> |
| </div> |
| <div class="refsect1"> |
| <a name="GSocket.other_details"></a><h2>Types and Values</h2> |
| <div class="refsect2"> |
| <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: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GSocketType"></a><h3>enum GSocketType</h3> |
| <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="refsect3"> |
| <a name="GSocketType.members"></a><h4>Members</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="300px" class="enum_members_name"> |
| <col class="enum_members_description"> |
| <col width="200px" class="enum_members_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="enum_member_name"><p><a name="G-SOCKET-TYPE-INVALID:CAPS"></a>G_SOCKET_TYPE_INVALID</p></td> |
| <td class="enum_member_description"> |
| <p>Type unknown or wrong</p> |
| </td> |
| <td class="enum_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="enum_member_name"><p><a name="G-SOCKET-TYPE-STREAM:CAPS"></a>G_SOCKET_TYPE_STREAM</p></td> |
| <td class="enum_member_description"> |
| <p>Reliable connection-based byte streams (e.g. TCP).</p> |
| </td> |
| <td class="enum_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="enum_member_name"><p><a name="G-SOCKET-TYPE-DATAGRAM:CAPS"></a>G_SOCKET_TYPE_DATAGRAM</p></td> |
| <td class="enum_member_description"> |
| <p>Connectionless, unreliable datagram passing. |
| (e.g. UDP)</p> |
| </td> |
| <td class="enum_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="enum_member_name"><p><a name="G-SOCKET-TYPE-SEQPACKET:CAPS"></a>G_SOCKET_TYPE_SEQPACKET</p></td> |
| <td class="enum_member_description"> |
| <p>Reliable connection-based passing of datagrams |
| of fixed maximum length (e.g. SCTP).</p> |
| </td> |
| <td class="enum_member_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GSocketProtocol"></a><h3>enum GSocketProtocol</h3> |
| <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="refsect3"> |
| <a name="GSocketProtocol.members"></a><h4>Members</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="300px" class="enum_members_name"> |
| <col class="enum_members_description"> |
| <col width="200px" class="enum_members_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="enum_member_name"><p><a name="G-SOCKET-PROTOCOL-UNKNOWN:CAPS"></a>G_SOCKET_PROTOCOL_UNKNOWN</p></td> |
| <td class="enum_member_description"> |
| <p>The protocol type is unknown</p> |
| </td> |
| <td class="enum_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="enum_member_name"><p><a name="G-SOCKET-PROTOCOL-DEFAULT:CAPS"></a>G_SOCKET_PROTOCOL_DEFAULT</p></td> |
| <td class="enum_member_description"> |
| <p>The default protocol for the family/type</p> |
| </td> |
| <td class="enum_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="enum_member_name"><p><a name="G-SOCKET-PROTOCOL-TCP:CAPS"></a>G_SOCKET_PROTOCOL_TCP</p></td> |
| <td class="enum_member_description"> |
| <p>TCP over IP</p> |
| </td> |
| <td class="enum_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="enum_member_name"><p><a name="G-SOCKET-PROTOCOL-UDP:CAPS"></a>G_SOCKET_PROTOCOL_UDP</p></td> |
| <td class="enum_member_description"> |
| <p>UDP over IP</p> |
| </td> |
| <td class="enum_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="enum_member_name"><p><a name="G-SOCKET-PROTOCOL-SCTP:CAPS"></a>G_SOCKET_PROTOCOL_SCTP</p></td> |
| <td class="enum_member_description"> |
| <p>SCTP over IP</p> |
| </td> |
| <td class="enum_member_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GSocketMsgFlags"></a><h3>enum GSocketMsgFlags</h3> |
| <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="refsect3"> |
| <a name="GSocketMsgFlags.members"></a><h4>Members</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="300px" class="enum_members_name"> |
| <col class="enum_members_description"> |
| <col width="200px" class="enum_members_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="enum_member_name"><p><a name="G-SOCKET-MSG-NONE:CAPS"></a>G_SOCKET_MSG_NONE</p></td> |
| <td class="enum_member_description"> |
| <p>No flags.</p> |
| </td> |
| <td class="enum_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="enum_member_name"><p><a name="G-SOCKET-MSG-OOB:CAPS"></a>G_SOCKET_MSG_OOB</p></td> |
| <td class="enum_member_description"> |
| <p>Request to send/receive out of band data.</p> |
| </td> |
| <td class="enum_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="enum_member_name"><p><a name="G-SOCKET-MSG-PEEK:CAPS"></a>G_SOCKET_MSG_PEEK</p></td> |
| <td class="enum_member_description"> |
| <p>Read data from the socket without removing it from |
| the queue.</p> |
| </td> |
| <td class="enum_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="enum_member_name"><p><a name="G-SOCKET-MSG-DONTROUTE:CAPS"></a>G_SOCKET_MSG_DONTROUTE</p></td> |
| <td class="enum_member_description"> |
| <p>Don't use a gateway to send out the packet, |
| only send to hosts on directly connected networks.</p> |
| </td> |
| <td class="enum_member_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GInputVector"></a><h3>struct GInputVector</h3> |
| <pre class="programlisting">struct GInputVector { |
| gpointer buffer; |
| gsize size; |
| }; |
| </pre> |
| <p>Structure used for scatter/gather data input. |
| You generally pass in an array of <a href="GSocket.html#GInputVector"><span class="type">GInputVectors</span></a> |
| and the operation will store the read data starting in the |
| first buffer, switching to the next as needed.</p> |
| <div class="refsect3"> |
| <a name="GInputVector.members"></a><h4>Members</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="300px" class="struct_members_name"> |
| <col class="struct_members_description"> |
| <col width="200px" class="struct_members_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="struct_member_name"><p><a href="../glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> <em class="structfield"><code><a name="GInputVector.buffer"></a>buffer</code></em>;</p></td> |
| <td class="struct_member_description"><p>Pointer to a buffer where data will be written.</p></td> |
| <td class="struct_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="struct_member_name"><p><a href="../glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> <em class="structfield"><code><a name="GInputVector.size"></a>size</code></em>;</p></td> |
| <td class="struct_member_description"><p>the available size in <em class="parameter"><code>buffer</code></em> |
| .</p></td> |
| <td class="struct_member_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GInputMessage"></a><h3>struct GInputMessage</h3> |
| <pre class="programlisting">struct GInputMessage { |
| GSocketAddress **address; |
| |
| GInputVector *vectors; |
| guint num_vectors; |
| |
| gsize bytes_received; |
| gint flags; |
| |
| GSocketControlMessage ***control_messages; |
| guint *num_control_messages; |
| }; |
| </pre> |
| <p>Structure used for scatter/gather data input when receiving multiple |
| messages or packets in one go. You generally pass in an array of empty |
| <a href="GSocket.html#GInputVector"><span class="type">GInputVectors</span></a> and the operation will use all the buffers as if they |
| were one buffer, and will set <em class="parameter"><code>bytes_received</code></em> |
| to the total number of bytes |
| received across all <a href="GSocket.html#GInputVector"><span class="type">GInputVectors</span></a>.</p> |
| <p>This structure closely mirrors <code class="literal">struct mmsghdr</code> and <code class="literal">struct msghdr</code> from |
| the POSIX sockets API (see <code class="literal">man 2 recvmmsg</code>).</p> |
| <p>If <em class="parameter"><code>address</code></em> |
| is non-<a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> then it is set to the source address the message |
| was received from, and the caller must free it afterwards.</p> |
| <p>If <em class="parameter"><code>control_messages</code></em> |
| is non-<a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> then it is set to an array of control |
| messages received with the message (if any), and the caller must free it |
| afterwards. <em class="parameter"><code>num_control_messages</code></em> |
| is set to the number of elements in |
| this array, which may be zero.</p> |
| <p>Flags relevant to this message will be returned in <em class="parameter"><code>flags</code></em> |
| . For example, |
| <code class="literal">MSG_EOR</code> or <code class="literal">MSG_TRUNC</code>.</p> |
| <div class="refsect3"> |
| <a name="GInputMessage.members"></a><h4>Members</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="300px" class="struct_members_name"> |
| <col class="struct_members_description"> |
| <col width="200px" class="struct_members_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="struct_member_name"><p><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> **<em class="structfield"><code><a name="GInputMessage.address"></a>address</code></em>;</p></td> |
| <td class="struct_member_description"><p> return location |
| for a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a>, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="struct_member_annotations"><span class="annotation">[<acronym title="NULL may be passed instead of a pointer to a location."><span class="acronym">optional</span></acronym>][<acronym title="Parameter for returning results. Default is transfer full."><span class="acronym">out</span></acronym>][<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="struct_member_name"><p><a class="link" href="GSocket.html#GInputVector" title="struct GInputVector"><span class="type">GInputVector</span></a> *<em class="structfield"><code><a name="GInputMessage.vectors"></a>vectors</code></em>;</p></td> |
| <td class="struct_member_description"><p> pointer to an |
| array of input vectors. </p></td> |
| <td class="struct_member_annotations"><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=num_vectors][<acronym title="Parameter for returning results. Default is transfer full."><span class="acronym">out</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="struct_member_name"><p><a href="../glib-Basic-Types.html#guint"><span class="type">guint</span></a> <em class="structfield"><code><a name="GInputMessage.num-vectors"></a>num_vectors</code></em>;</p></td> |
| <td class="struct_member_description"><p>the number of input vectors pointed to by <em class="parameter"><code>vectors</code></em> |
| </p></td> |
| <td class="struct_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="struct_member_name"><p><a href="../glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> <em class="structfield"><code><a name="GInputMessage.bytes-received"></a>bytes_received</code></em>;</p></td> |
| <td class="struct_member_description"><p> will be set to the number of bytes that have been |
| received. </p></td> |
| <td class="struct_member_annotations"><span class="annotation">[<acronym title="Parameter for returning results. Default is transfer full."><span class="acronym">out</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="struct_member_name"><p><a href="../glib-Basic-Types.html#gint"><span class="type">gint</span></a> <em class="structfield"><code><a name="GInputMessage.flags"></a>flags</code></em>;</p></td> |
| <td class="struct_member_description"><p> collection of <a class="link" href="GSocket.html#GSocketMsgFlags" title="enum GSocketMsgFlags"><span class="type">GSocketMsgFlags</span></a> for the received message, |
| outputted by the call. </p></td> |
| <td class="struct_member_annotations"><span class="annotation">[<acronym title="Parameter for returning results. Default is transfer full."><span class="acronym">out</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="struct_member_name"><p><a class="link" href="GSocketControlMessage.html" title="GSocketControlMessage"><span class="type">GSocketControlMessage</span></a> ***<em class="structfield"><code><a name="GInputMessage.control-messages"></a>control_messages</code></em>;</p></td> |
| <td class="struct_member_description"><p>(array length=num_control_messages) (optional) |
| (out) (transfer full): return location for a |
| caller-allocated array of <a href="GSocketControlMessage.html#GSocketControlMessage-struct"><span class="type">GSocketControlMessages</span></a>, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a></p></td> |
| <td class="struct_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="struct_member_name"><p><a href="../glib-Basic-Types.html#guint"><span class="type">guint</span></a> *<em class="structfield"><code><a name="GInputMessage.num-control-messages"></a>num_control_messages</code></em>;</p></td> |
| <td class="struct_member_description"><p> return location for the number of |
| elements in <em class="parameter"><code>control_messages</code></em> |
| . </p></td> |
| <td class="struct_member_annotations"><span class="annotation">[<acronym title="Parameter for returning results. Default is transfer full."><span class="acronym">out</span></acronym>][<acronym title="NULL may be passed instead of a pointer to a location."><span class="acronym">optional</span></acronym>]</span></td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-48.html#api-index-2.48">2.48</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GOutputVector"></a><h3>struct GOutputVector</h3> |
| <pre class="programlisting">struct GOutputVector { |
| gconstpointer buffer; |
| gsize size; |
| }; |
| </pre> |
| <p>Structure used for scatter/gather data output. |
| You generally pass in an array of <a href="GSocket.html#GOutputVector"><span class="type">GOutputVectors</span></a> |
| and the operation will use all the buffers as if they were |
| one buffer.</p> |
| <div class="refsect3"> |
| <a name="GOutputVector.members"></a><h4>Members</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="300px" class="struct_members_name"> |
| <col class="struct_members_description"> |
| <col width="200px" class="struct_members_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="struct_member_name"><p><a href="../glib-Basic-Types.html#gconstpointer"><span class="type">gconstpointer</span></a> <em class="structfield"><code><a name="GOutputVector.buffer"></a>buffer</code></em>;</p></td> |
| <td class="struct_member_description"><p>Pointer to a buffer of data to read.</p></td> |
| <td class="struct_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="struct_member_name"><p><a href="../glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> <em class="structfield"><code><a name="GOutputVector.size"></a>size</code></em>;</p></td> |
| <td class="struct_member_description"><p>the size of <em class="parameter"><code>buffer</code></em> |
| .</p></td> |
| <td class="struct_member_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-22.html#api-index-2.22">2.22</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GOutputMessage"></a><h3>struct GOutputMessage</h3> |
| <pre class="programlisting">struct GOutputMessage { |
| GSocketAddress *address; |
| |
| GOutputVector *vectors; |
| guint num_vectors; |
| |
| guint bytes_sent; |
| |
| GSocketControlMessage **control_messages; |
| guint num_control_messages; |
| }; |
| </pre> |
| <p>Structure used for scatter/gather data output when sending multiple |
| messages or packets in one go. You generally pass in an array of |
| <a href="GSocket.html#GOutputVector"><span class="type">GOutputVectors</span></a> and the operation will use all the buffers as if they |
| were one buffer.</p> |
| <p>If <em class="parameter"><code>address</code></em> |
| is <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> then the message is sent to the default receiver |
| (as previously set by <a class="link" href="GSocket.html#g-socket-connect" title="g_socket_connect ()"><code class="function">g_socket_connect()</code></a>).</p> |
| <div class="refsect3"> |
| <a name="GOutputMessage.members"></a><h4>Members</h4> |
| <div class="informaltable"><table class="informaltable" width="100%" border="0"> |
| <colgroup> |
| <col width="300px" class="struct_members_name"> |
| <col class="struct_members_description"> |
| <col width="200px" class="struct_members_annotations"> |
| </colgroup> |
| <tbody> |
| <tr> |
| <td class="struct_member_name"><p><a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a> *<em class="structfield"><code><a name="GOutputMessage.address"></a>address</code></em>;</p></td> |
| <td class="struct_member_description"><p> a <a class="link" href="GSocketAddress.html" title="GSocketAddress"><span class="type">GSocketAddress</span></a>, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="struct_member_annotations"><span class="annotation">[<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="struct_member_name"><p><a class="link" href="GSocket.html#GOutputVector" title="struct GOutputVector"><span class="type">GOutputVector</span></a> *<em class="structfield"><code><a name="GOutputMessage.vectors"></a>vectors</code></em>;</p></td> |
| <td class="struct_member_description"><p>pointer to an array of output vectors</p></td> |
| <td class="struct_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="struct_member_name"><p><a href="../glib-Basic-Types.html#guint"><span class="type">guint</span></a> <em class="structfield"><code><a name="GOutputMessage.num-vectors"></a>num_vectors</code></em>;</p></td> |
| <td class="struct_member_description"><p>the number of output vectors pointed to by <em class="parameter"><code>vectors</code></em> |
| .</p></td> |
| <td class="struct_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="struct_member_name"><p><a href="../glib-Basic-Types.html#guint"><span class="type">guint</span></a> <em class="structfield"><code><a name="GOutputMessage.bytes-sent"></a>bytes_sent</code></em>;</p></td> |
| <td class="struct_member_description"><p>initialize to 0. Will be set to the number of bytes |
| that have been sent</p></td> |
| <td class="struct_member_annotations"> </td> |
| </tr> |
| <tr> |
| <td class="struct_member_name"><p><a class="link" href="GSocketControlMessage.html" title="GSocketControlMessage"><span class="type">GSocketControlMessage</span></a> **<em class="structfield"><code><a name="GOutputMessage.control-messages"></a>control_messages</code></em>;</p></td> |
| <td class="struct_member_description"><p> a pointer |
| to an array of <a href="GSocketControlMessage.html#GSocketControlMessage-struct"><span class="type">GSocketControlMessages</span></a>, or <a href="../glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. </p></td> |
| <td class="struct_member_annotations"><span class="annotation">[<acronym title="Parameter points to an array of items."><span class="acronym">array</span></acronym> length=num_control_messages][<acronym title="NULL is OK, both for passing and for returning."><span class="acronym">allow-none</span></acronym>]</span></td> |
| </tr> |
| <tr> |
| <td class="struct_member_name"><p><a href="../glib-Basic-Types.html#guint"><span class="type">guint</span></a> <em class="structfield"><code><a name="GOutputMessage.num-control-messages"></a>num_control_messages</code></em>;</p></td> |
| <td class="struct_member_description"><p>number of elements in <em class="parameter"><code>control_messages</code></em> |
| .</p></td> |
| <td class="struct_member_annotations"> </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <p class="since">Since: <a class="link" href="api-index-2-44.html#api-index-2.44">2.44</a></p> |
| </div> |
| </div> |
| <div class="refsect1"> |
| <a name="GSocket.property-details"></a><h2>Property Details</h2> |
| <div class="refsect2"> |
| <a name="GSocket--blocking"></a><h3>The <code class="literal">“blocking”</code> property</h3> |
| <pre class="programlisting"> “blocking” <a href="../glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a></pre> |
| <p>Whether or not I/O on this socket is blocking.</p> |
| <p>Flags: Read / Write</p> |
| <p>Default value: TRUE</p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GSocket--broadcast"></a><h3>The <code class="literal">“broadcast”</code> property</h3> |
| <pre class="programlisting"> “broadcast” <a href="../glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a></pre> |
| <p>Whether the socket should allow sending to broadcast addresses.</p> |
| <p>Flags: Read / Write</p> |
| <p>Default value: FALSE</p> |
| <p class="since">Since: <a class="link" href="api-index-2-32.html#api-index-2.32">2.32</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <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></pre> |
| <p>The sockets address family.</p> |
| <p>Flags: Read / Write / Construct Only</p> |
| <p>Default value: G_SOCKET_FAMILY_INVALID</p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GSocket--fd"></a><h3>The <code class="literal">“fd”</code> property</h3> |
| <pre class="programlisting"> “fd” <a href="../glib-Basic-Types.html#gint"><span class="type">gint</span></a></pre> |
| <p>The sockets file descriptor.</p> |
| <p>Flags: Read / Write / Construct Only</p> |
| <p>Default value: -1</p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GSocket--keepalive"></a><h3>The <code class="literal">“keepalive”</code> property</h3> |
| <pre class="programlisting"> “keepalive” <a href="../glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a></pre> |
| <p>Keep connection alive by sending periodic pings.</p> |
| <p>Flags: Read / Write</p> |
| <p>Default value: FALSE</p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GSocket--listen-backlog"></a><h3>The <code class="literal">“listen-backlog”</code> property</h3> |
| <pre class="programlisting"> “listen-backlog” <a href="../glib-Basic-Types.html#gint"><span class="type">gint</span></a></pre> |
| <p>Outstanding connections in the listen queue.</p> |
| <p>Flags: Read / Write</p> |
| <p>Allowed values: [0,128]</p> |
| <p>Default value: 10</p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <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> *</pre> |
| <p>The local address the socket is bound to.</p> |
| <p>Flags: Read</p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GSocket--multicast-loopback"></a><h3>The <code class="literal">“multicast-loopback”</code> property</h3> |
| <pre class="programlisting"> “multicast-loopback” <a href="../glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a></pre> |
| <p>Whether outgoing multicast packets loop back to the local host.</p> |
| <p>Flags: Read / Write</p> |
| <p>Default value: TRUE</p> |
| <p class="since">Since: <a class="link" href="api-index-2-32.html#api-index-2.32">2.32</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GSocket--multicast-ttl"></a><h3>The <code class="literal">“multicast-ttl”</code> property</h3> |
| <pre class="programlisting"> “multicast-ttl” <a href="../glib-Basic-Types.html#guint"><span class="type">guint</span></a></pre> |
| <p>Time-to-live out outgoing multicast packets</p> |
| <p>Flags: Read / Write</p> |
| <p>Default value: 1</p> |
| <p class="since">Since: <a class="link" href="api-index-2-32.html#api-index-2.32">2.32</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <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></pre> |
| <p>The id of the protocol to use, or -1 for unknown.</p> |
| <p>Flags: Read / Write / Construct Only</p> |
| <p>Default value: G_SOCKET_PROTOCOL_UNKNOWN</p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <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> *</pre> |
| <p>The remote address the socket is connected to.</p> |
| <p>Flags: Read</p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GSocket--timeout"></a><h3>The <code class="literal">“timeout”</code> property</h3> |
| <pre class="programlisting"> “timeout” <a href="../glib-Basic-Types.html#guint"><span class="type">guint</span></a></pre> |
| <p>The timeout in seconds on socket I/O</p> |
| <p>Flags: Read / Write</p> |
| <p>Default value: 0</p> |
| <p class="since">Since: <a class="link" href="api-index-2-26.html#api-index-2.26">2.26</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <a name="GSocket--ttl"></a><h3>The <code class="literal">“ttl”</code> property</h3> |
| <pre class="programlisting"> “ttl” <a href="../glib-Basic-Types.html#guint"><span class="type">guint</span></a></pre> |
| <p>Time-to-live for outgoing unicast packets</p> |
| <p>Flags: Read / Write</p> |
| <p>Default value: 0</p> |
| <p class="since">Since: <a class="link" href="api-index-2-32.html#api-index-2.32">2.32</a></p> |
| </div> |
| <hr> |
| <div class="refsect2"> |
| <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></pre> |
| <p>The sockets type.</p> |
| <p>Flags: Read / Write / Construct Only</p> |
| <p>Default value: G_SOCKET_TYPE_STREAM</p> |
| </div> |
| </div> |
| <div class="refsect1"> |
| <a name="GSocket.see-also"></a><h2>See Also</h2> |
| <p><a class="link" href="GInitable.html" title="GInitable"><span class="type">GInitable</span></a>, <a class="link" href="gio-gnetworking.h.html" title="gnetworking.h"><gnetworking.h></a></p> |
| </div> |
| </div> |
| <div class="footer"> |
| <hr>Generated by GTK-Doc V1.25.1</div> |
| </body> |
| </html> |