2008-01-04 06:59:49 +00:00
|
|
|
#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
|
2008-06-08 10:38:33 +00:00
|
|
|
version 2 of the License, or (at your option) any later version.
|
2008-01-04 06:59:49 +00:00
|
|
|
|
|
|
|
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
|
2019-12-09 23:36:00 +00:00
|
|
|
Lesser General Public License for more details.
|
2008-01-04 06:59:49 +00:00
|
|
|
|
|
|
|
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., 51 Franklin Street, Fifth Floor,
|
2019-12-09 23:36:00 +00:00
|
|
|
Boston, MA 02110 USA.
|
2008-01-04 06:59:49 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2011-12-15 09:42:39 +00:00
|
|
|
|
|
|
|
#if defined(HAVE_SYS_FCNTL_H)
|
|
|
|
# include <sys/fcntl.h>
|
|
|
|
#elif defined(HAVE_FCNTL_H)
|
|
|
|
# include <fcntl.h>
|
|
|
|
#endif
|
|
|
|
|
2008-01-04 06:59:49 +00:00
|
|
|
|
2016-03-09 13:16:16 +00:00
|
|
|
#if defined(_WIN32)
|
2008-01-04 06:59:49 +00:00
|
|
|
|
2016-06-27 18:04:30 +00:00
|
|
|
#include <winsock2.h>
|
2008-01-04 06:59:49 +00:00
|
|
|
#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()
|
2024-02-13 11:19:36 +00:00
|
|
|
#define GSWOULDBLOCK(X) (WSAEWOULDBLOCK == (X) || WSAEINPROGRESS == (X))
|
2008-01-04 06:59:49 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/un.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
2010-02-14 10:48:10 +00:00
|
|
|
#include <netdb.h>
|
2008-01-04 06:59:49 +00:00
|
|
|
|
|
|
|
#ifndef AF_LOCAL
|
|
|
|
#define AF_LOCAL AF_UNIX
|
|
|
|
#endif
|
|
|
|
#ifndef PF_LOCAL
|
|
|
|
#define PF_LOCAL PF_UNIX
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SOCKET int /* Socket type */
|
2008-01-09 16:11:10 +00:00
|
|
|
#define INVALID_SOCKET -1
|
2008-01-04 06:59:49 +00:00
|
|
|
#define BADSOCKET(X) ((X) < 0)
|
|
|
|
#define GSNETERROR errno
|
2024-02-13 11:19:36 +00:00
|
|
|
#define GSWOULDBLOCK(X) (EINPROGRESS == (X)\
|
|
|
|
|| EALREADY == (X)\
|
|
|
|
|| EINTR == (X)\
|
|
|
|
|| EAGAIN == (X))
|
2008-01-04 06:59:49 +00:00
|
|
|
|
2016-03-09 13:16:16 +00:00
|
|
|
#endif /* _WIN32 */
|
2008-01-04 06:59:49 +00:00
|
|
|
|
2010-10-01 09:22:52 +00:00
|
|
|
/* 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
|
|
|
|
|
2008-01-04 06:59:49 +00:00
|
|
|
#ifndef INADDRSZ
|
|
|
|
#define INADDRSZ 4
|
|
|
|
#endif
|
|
|
|
|
2008-01-10 16:05:41 +00:00
|
|
|
#ifndef IN6ADDRSZ
|
|
|
|
#define IN6ADDRSZ 16
|
|
|
|
#endif
|
|
|
|
|
2010-02-25 10:00:48 +00:00
|
|
|
#if !defined(HAVE_SOCKLEN_T)
|
|
|
|
# if !defined(socklen_t)
|
|
|
|
# define socklen_t uint32_t
|
|
|
|
# endif
|
2008-01-04 06:59:49 +00:00
|
|
|
#endif
|
|
|
|
|
2012-03-01 19:39:20 +00:00
|
|
|
#import "GSPrivate.h"
|
|
|
|
|
2011-10-03 16:03:19 +00:00
|
|
|
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;
|
|
|
|
|
2008-01-04 06:59:49 +00:00
|
|
|
#endif
|