aboutsummaryrefslogtreecommitdiffstats
path: root/sdk/net/socket.h
blob: b9bd190f6880d1a0d2dd080ea3a533b51e7a831d (plain)
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
/*
 * Portable include for access of socket services.
 * $Id$
 * Copyright (c) 1997 by Tycho Softworks.
 * For conditions of distribution and reuse see product license.
 */

#ifndef	__NET_SOCKET_H__
#define	__NET_SOCKET_H__

#ifndef	__STD_FILES_H__
#include <std/files.h>
#endif

#ifndef	__STD_TYPES_H__
#include <std/types.h>
#endif

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>

typedef	int	SOCKET;
#define	INVALID_SOCKET	-1

#ifdef	__cplusplus
extern "C" {
#endif

#ifdef	__NAMESPACE
#define	init_sockets	__NAMESPACE(init_sockets)
#define	gethost		__NAMESPACE(gethost)
#define	getservice	__NAMESPACE(getservice)
#define	peername	__NAMESPACE(peername)
#define	peeraddr	__NAMESPACE(peeraddr)
#define	homename	__NAMESPACE(homename)
#define	homeaddr	__NAMESPACE(homeaddr)
#define	endsocket	__NAMESPACE(endsocket)
#define	udpsocket	__NAMESPACE(udpsocket)
#define	tcpsocket	__NAMESPACE(tcpsocket)
#define	getsocket	__NAMESPACE(getsocket)
#endif

bool	init_sockets(void);
struct	hostent	*gethost(const char *host);
struct	in_addr *getnetaddr(const char *addr);
int	getservice(const char *service);
char	*peername(SOCKET so);
char	*peeraddr(SOCKET so);
char	*homename(SOCKET so);
char	*homeaddr(SOCKET so);
void	endsocket(SOCKET so);
SOCKET	udpsocket(char *mask, int port);
SOCKET	tcpsocket(char *mask, int port, int backlog);
SOCKET	getsocket(const char *host, int port, int socktype);
#ifdef	__cplusplus
}
#endif

#endif