1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
3 /* GIO - GLib Input, Output and Streaming Library
5 * Copyright (C) 2011 Red Hat, Inc.
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.
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.
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.
25 #include "gnetworking.h"
29 * @title: gnetworking.h
30 * @short_description: System networking includes
31 * @include: gio/gnetworking.h
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.
37 * This can be used, for example, if you want to call setsockopt()
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.
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
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).
64 g_networking_init (void)
67 static volatile gsize inited = 0;
69 if (g_once_init_enter (&inited))
73 if (WSAStartup (MAKEWORD (2, 0), &wsadata) != 0)
74 g_error ("Windows Sockets could not be initialized");
76 g_once_init_leave (&inited, 1);