This repository was archived by the owner on Nov 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinet_socket.h
More file actions
44 lines (35 loc) · 1.74 KB
/
inet_socket.h
File metadata and controls
44 lines (35 loc) · 1.74 KB
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
#ifndef INET_SOCKET_H
#define INET_SOCKET_H
#include <sys/socket.h>
#include <sys/un.h>
/* The following arguments are common to several of the routines
below:
'host': NULL for loopback IP address, or
a host name or numeric IP address
'service': either a name or a port number
'type': either SOCK_STREAM or SOCK_DGRAM
*/
/* Create socket and connect it to the address specified by
'host' + 'service'/'type'. Return socket descriptor on success,
or -1 on error */
int inetConnect(const char *host, const char *service, int type);
/* Create stream socket, bound to wildcard IP address + port given in
'service'. Make the socket a listening socket, with the specified
'backlog'. Return socket descriptor on success, or -1 on error. */
int inetListen(const char *service, int backlog, socklen_t *addrlen);
/* Create socket bound to wildcard IP address + port given in
'service'. Return socket descriptor on success, or -1 on error. */
int inetBind(const char *service, int type, socklen_t *addrlen);
/* Given a socket address in 'addr', whose length is specified in
'addrlen', return a null-terminated string containing the host and
service names in the form "(hostname, port#)". The string is
returned in the buffer pointed to by 'addrStr', and this value is
also returned as the function result. The caller must specify the
size of the 'addrStr' buffer in 'addrStrLen'. */
char *inetAddressStr(const struct sockaddr *addr, socklen_t addrlen,
char *addrStr, int addrStrLen);
/* Suggested length for string buffer that caller
should pass to inetAddressStr(). Must be greater
than (NI_MAXHOST + NI_MAXSERV + 4) */
#define IS_ADDR_STR_LEN 4096
#endif