-
Notifications
You must be signed in to change notification settings - Fork 284
/
Copy pathGSNetwork.h
118 lines (90 loc) · 3.03 KB
/
GSNetwork.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#ifndef INCLUDED_GSNETWORK_H
#define INCLUDED_GSNETWORK_H 1
/* GSNetwork.h - This collects the system header files needed for
networking code. In future it may also contain internal wrappers
to standardise networking operations.
Copyright (C) 2008, Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald <rfm@gnu.org>
Created: Jan 2008
This file is part of the GNUstep Base Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 31 Milk Street #960789 Boston, MA 02196 USA.
*/
#include <sys/types.h>
#include <sys/stat.h>
#if defined(HAVE_SYS_FCNTL_H)
# include <sys/fcntl.h>
#elif defined(HAVE_FCNTL_H)
# include <fcntl.h>
#endif
#if defined(_WIN32)
#include <winsock2.h>
#include <io.h>
#include <ws2tcpip.h>
#include <wininet.h>
#if !defined(EAFNOSUPPORT)
#define EAFNOSUPPORT WSAEAFNOSUPPORT
#endif
#define BADSOCKET(X) ((X) == INVALID_SOCKET)
#define GSNETERROR WSAGetLastError()
#define GSWOULDBLOCK(X) (WSAEWOULDBLOCK == (X) || WSAEINPROGRESS == (X))
#else
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#ifndef AF_LOCAL
#define AF_LOCAL AF_UNIX
#endif
#ifndef PF_LOCAL
#define PF_LOCAL PF_UNIX
#endif
#define SOCKET int /* Socket type */
#define INVALID_SOCKET -1
#define BADSOCKET(X) ((X) < 0)
#define GSNETERROR errno
#define GSWOULDBLOCK(X) (EINPROGRESS == (X)\
|| EALREADY == (X)\
|| EINTR == (X)\
|| EAGAIN == (X))
#endif /* _WIN32 */
/* The backlog argument to the listen() system call.
* Systems should silently truncate the backlog if they don't support one
* as large as we set, so it makes sense to set a large value in order to
* support high volume applications.
*/
#define GSBACKLOG 10000
#ifndef INADDRSZ
#define INADDRSZ 4
#endif
#ifndef IN6ADDRSZ
#define IN6ADDRSZ 16
#endif
#if !defined(HAVE_SOCKLEN_T)
# if !defined(socklen_t)
# define socklen_t uint32_t
# endif
#endif
#import "GSPrivate.h"
NSString*
GSPrivateSockaddrHost(struct sockaddr *addr) GS_ATTRIB_PRIVATE;
unsigned
GSPrivateSockaddrLength(struct sockaddr *addr) GS_ATTRIB_PRIVATE;
NSString*
GSPrivateSockaddrName(struct sockaddr *addr) GS_ATTRIB_PRIVATE;
uint16_t
GSPrivateSockaddrPort(struct sockaddr *addr) GS_ATTRIB_PRIVATE;
BOOL
GSPrivateSockaddrSetup(NSString *machine, uint16_t port, NSString *service,
NSString *protocol, struct sockaddr *sin) GS_ATTRIB_PRIVATE;
#endif