Tizen 2.1 base
[platform/upstream/glib2.0.git] / docs / reference / gio / html / GThreadedSocketService.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>GThreadedSocketService</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="GIO Reference Manual">
8 <link rel="up" href="highlevel-socket.html" title="High-level network functionallity">
9 <link rel="prev" href="GSocketService.html" title="GSocketService">
10 <link rel="next" href="GNetworkMonitor.html" title="GNetworkMonitor">
11 <meta name="generator" content="GTK-Doc V1.18 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 </head>
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
16 <tr valign="middle">
17 <td><a accesskey="p" href="GSocketService.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
18 <td><a accesskey="u" href="highlevel-socket.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
19 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
20 <th width="100%" align="center">GIO Reference Manual</th>
21 <td><a accesskey="n" href="GNetworkMonitor.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
22 </tr>
23 <tr><td colspan="5" class="shortcuts">
24 <a href="#GThreadedSocketService.synopsis" class="shortcut">Top</a>
25                    | 
26                   <a href="#GThreadedSocketService.description" class="shortcut">Description</a>
27                    | 
28                   <a href="#GThreadedSocketService.object-hierarchy" class="shortcut">Object Hierarchy</a>
29                    | 
30                   <a href="#GThreadedSocketService.properties" class="shortcut">Properties</a>
31                    | 
32                   <a href="#GThreadedSocketService.signals" class="shortcut">Signals</a>
33 </td></tr>
34 </table>
35 <div class="refentry">
36 <a name="GThreadedSocketService"></a><div class="titlepage"></div>
37 <div class="refnamediv"><table width="100%"><tr>
38 <td valign="top">
39 <h2><span class="refentrytitle"><a name="GThreadedSocketService.top_of_page"></a>GThreadedSocketService</span></h2>
40 <p>GThreadedSocketService — A threaded GSocketService</p>
41 </td>
42 <td valign="top" align="right"></td>
43 </tr></table></div>
44 <div class="refsynopsisdiv">
45 <a name="GThreadedSocketService.synopsis"></a><h2>Synopsis</h2>
46 <pre class="synopsis">                    <a class="link" href="GThreadedSocketService.html#GThreadedSocketService-struct" title="GThreadedSocketService">GThreadedSocketService</a>;
47 <a class="link" href="GSocketService.html" title="GSocketService"><span class="returnvalue">GSocketService</span></a> *    <a class="link" href="GThreadedSocketService.html#g-threaded-socket-service-new" title="g_threaded_socket_service_new ()">g_threaded_socket_service_new</a>       (<em class="parameter"><code><span class="type">int</span> max_threads</code></em>);
48 </pre>
49 </div>
50 <div class="refsect1">
51 <a name="GThreadedSocketService.object-hierarchy"></a><h2>Object Hierarchy</h2>
52 <pre class="synopsis">
53   <a href="./../gobject/gobject/gobject-The-Base-Object-Type.html#GObject">GObject</a>
54    +----<a class="link" href="GSocketListener.html" title="GSocketListener">GSocketListener</a>
55          +----<a class="link" href="GSocketService.html" title="GSocketService">GSocketService</a>
56                +----GThreadedSocketService
57 </pre>
58 </div>
59 <div class="refsect1">
60 <a name="GThreadedSocketService.properties"></a><h2>Properties</h2>
61 <pre class="synopsis">
62   "<a class="link" href="GThreadedSocketService.html#GThreadedSocketService--max-threads" title='The "max-threads" property'>max-threads</a>"              <a href="./../glib/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a>                  : Read / Write / Construct Only
63 </pre>
64 </div>
65 <div class="refsect1">
66 <a name="GThreadedSocketService.signals"></a><h2>Signals</h2>
67 <pre class="synopsis">
68   "<a class="link" href="GThreadedSocketService.html#GThreadedSocketService-run" title='The "run" signal'>run</a>"                                            : <a href="./../gobject/gobject/gobject-Signals.html#G-SIGNAL-RUN-LAST:CAPS"><code class="literal">Run Last</code></a>
69 </pre>
70 </div>
71 <div class="refsect1">
72 <a name="GThreadedSocketService.description"></a><h2>Description</h2>
73 <p>
74 A <a class="link" href="GThreadedSocketService.html" title="GThreadedSocketService"><span class="type">GThreadedSocketService</span></a> is a simple subclass of <a class="link" href="GSocketService.html" title="GSocketService"><span class="type">GSocketService</span></a>
75 that handles incoming connections by creating a worker thread and
76 dispatching the connection to it by emitting the
77 <a class="link" href="GThreadedSocketService.html#GThreadedSocketService-run" title='The "run" signal'><span class="type">"run"</span></a> signal in the new thread.
78 </p>
79 <p>
80 The signal handler may perform blocking IO and need not return
81 until the connection is closed.
82 </p>
83 <p>
84 The service is implemented using a thread pool, so there is a
85 limited amount of threads available to serve incoming requests.
86 The service automatically stops the <a class="link" href="GSocketService.html" title="GSocketService"><span class="type">GSocketService</span></a> from accepting
87 new connections when all threads are busy.
88 </p>
89 <p>
90 As with <a class="link" href="GSocketService.html" title="GSocketService"><span class="type">GSocketService</span></a>, you may connect to <a class="link" href="GThreadedSocketService.html#GThreadedSocketService-run" title='The "run" signal'><span class="type">"run"</span></a>,
91 or subclass and override the default handler.
92 </p>
93 </div>
94 <div class="refsect1">
95 <a name="GThreadedSocketService.details"></a><h2>Details</h2>
96 <div class="refsect2">
97 <a name="GThreadedSocketService-struct"></a><h3>GThreadedSocketService</h3>
98 <pre class="programlisting">typedef struct _GThreadedSocketService GThreadedSocketService;</pre>
99 <p>
100 A helper class for handling accepting incoming connections in the
101 glib mainloop and handling them in a thread.
102 </p>
103 <p class="since">Since 2.22</p>
104 </div>
105 <hr>
106 <div class="refsect2">
107 <a name="g-threaded-socket-service-new"></a><h3>g_threaded_socket_service_new ()</h3>
108 <pre class="programlisting"><a class="link" href="GSocketService.html" title="GSocketService"><span class="returnvalue">GSocketService</span></a> *    g_threaded_socket_service_new       (<em class="parameter"><code><span class="type">int</span> max_threads</code></em>);</pre>
109 <p>
110 Creates a new <a class="link" href="GThreadedSocketService.html" title="GThreadedSocketService"><span class="type">GThreadedSocketService</span></a> with no listeners. Listeners
111 must be added with one of the <a class="link" href="GSocketListener.html" title="GSocketListener"><span class="type">GSocketListener</span></a> "add" methods.
112 </p>
113 <div class="variablelist"><table border="0">
114 <col align="left" valign="top">
115 <tbody>
116 <tr>
117 <td><p><span class="term"><em class="parameter"><code>max_threads</code></em> :</span></p></td>
118 <td>the maximal number of threads to execute concurrently
119 handling incoming clients, -1 means no limit</td>
120 </tr>
121 <tr>
122 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
123 <td>a new <a class="link" href="GSocketService.html" title="GSocketService"><span class="type">GSocketService</span></a>.</td>
124 </tr>
125 </tbody>
126 </table></div>
127 <p class="since">Since 2.22</p>
128 </div>
129 </div>
130 <div class="refsect1">
131 <a name="GThreadedSocketService.property-details"></a><h2>Property Details</h2>
132 <div class="refsect2">
133 <a name="GThreadedSocketService--max-threads"></a><h3>The <code class="literal">"max-threads"</code> property</h3>
134 <pre class="programlisting">  "max-threads"              <a href="./../glib/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a>                  : Read / Write / Construct Only</pre>
135 <p>The max number of threads handling clients for this service.</p>
136 <p>Allowed values: &gt;= G_MAXULONG</p>
137 <p>Default value: 10</p>
138 </div>
139 </div>
140 <div class="refsect1">
141 <a name="GThreadedSocketService.signal-details"></a><h2>Signal Details</h2>
142 <div class="refsect2">
143 <a name="GThreadedSocketService-run"></a><h3>The <code class="literal">"run"</code> signal</h3>
144 <pre class="programlisting"><a href="./../glib/glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            user_function                      (<a class="link" href="GThreadedSocketService.html" title="GThreadedSocketService"><span class="type">GThreadedSocketService</span></a> *service,
145                                                         <a class="link" href="GSocketConnection.html" title="GSocketConnection"><span class="type">GSocketConnection</span></a>      *connection,
146                                                         <a href="./../gobject/gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a>                *source_object,
147                                                         <a href="./../glib/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a>                user_data)          : <a href="./../gobject/gobject/gobject-Signals.html#G-SIGNAL-RUN-LAST:CAPS"><code class="literal">Run Last</code></a></pre>
148 <p>
149 The ::run signal is emitted in a worker thread in response to an
150 incoming connection. This thread is dedicated to handling
151 <em class="parameter"><code>connection</code></em> and may perform blocking IO. The signal handler need
152 not return until the connection is closed.
153 </p>
154 <div class="variablelist"><table border="0">
155 <col align="left" valign="top">
156 <tbody>
157 <tr>
158 <td><p><span class="term"><em class="parameter"><code>service</code></em> :</span></p></td>
159 <td>the <a class="link" href="GThreadedSocketService.html" title="GThreadedSocketService"><span class="type">GThreadedSocketService</span></a>.</td>
160 </tr>
161 <tr>
162 <td><p><span class="term"><em class="parameter"><code>connection</code></em> :</span></p></td>
163 <td>a new <a class="link" href="GSocketConnection.html" title="GSocketConnection"><span class="type">GSocketConnection</span></a> object.</td>
164 </tr>
165 <tr>
166 <td><p><span class="term"><em class="parameter"><code>source_object</code></em> :</span></p></td>
167 <td>the source_object passed to <a class="link" href="GSocketListener.html#g-socket-listener-add-address" title="g_socket_listener_add_address ()"><code class="function">g_socket_listener_add_address()</code></a>.</td>
168 </tr>
169 <tr>
170 <td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
171 <td>user data set when the signal handler was connected.</td>
172 </tr>
173 <tr>
174 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
175 <td>
176 <a href="./../glib/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> to stop further signal handlers from being called</td>
177 </tr>
178 </tbody>
179 </table></div>
180 </div>
181 </div>
182 <div class="refsect1">
183 <a name="GThreadedSocketService.see-also"></a><h2>See Also</h2>
184 <a class="link" href="GSocketService.html" title="GSocketService"><span class="type">GSocketService</span></a>.
185 </div>
186 </div>
187 <div class="footer">
188 <hr>
189           Generated by GTK-Doc V1.18</div>
190 </body>
191 </html>