Make GSettingsSchemaKey public
[platform/upstream/glib.git] / gio / gnetworking.c
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2
3 /* GIO - GLib Input, Output and Streaming Library
4  *
5  * Copyright (C) 2011 Red Hat, Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General
18  * Public License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #include "config.h"
24
25 #include "gnetworking.h"
26
27 /**
28  * SECTION:gnetworking
29  * @title: gnetworking.h
30  * @short_description: System networking includes
31  * @include: gio/gnetworking.h
32  *
33  * The <literal>gnetworking.h</literal> header can be included to get
34  * various low-level networking-related system headers, automatically
35  * taking care of certain portability issues for you.
36  *
37  * This can be used, for example, if you want to call setsockopt()
38  * on a #GSocket.
39  *
40  * Note that while WinSock has many of the same APIs as the
41  * traditional UNIX socket API, most of them behave at least slightly
42  * differently (particularly with respect to error handling). If you
43  * want your code to work under both UNIX and Windows, you will need
44  * to take these differences into account.
45  *
46  * Also, under glibc, certain non-portable functions are only visible
47  * in the headers if you define <literal>_GNU_SOURCE</literal> before
48  * including them. Note that this symbol must be defined before
49  * including <emphasis>any</emphasis> headers, or it may not take
50  * effect.
51  */
52
53 /**
54  * g_networking_init:
55  *
56  * Initializes the platform networking libraries (eg, on Windows, this
57  * calls WSAStartup()). GLib will call this itself if it is needed, so
58  * you only need to call it if you directly call system networking
59  * functions (without calling any GLib networking functions first).
60  *
61  * Since: 2.36
62  */
63 void
64 g_networking_init (void)
65 {
66 #ifdef G_OS_WIN32
67   static volatile gsize inited = 0;
68
69   if (g_once_init_enter (&inited))
70     {
71       WSADATA wsadata;
72
73       if (WSAStartup (MAKEWORD (2, 0), &wsadata) != 0)
74         g_error ("Windows Sockets could not be initialized");
75       
76       g_once_init_leave (&inited, 1);
77     }
78 #endif
79 }