-
Notifications
You must be signed in to change notification settings - Fork 0
/
mnet.h
56 lines (46 loc) · 1.09 KB
/
mnet.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
#ifndef MNET_H
#define MNET_H
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
TCP = 1,
UDP,
EITHER
} mSockType;
/*
* Run getaddrinfo on the host and service provided.
* 0 good, non-zero bad.
*/
int maddrlookup(const char *host, const char *service, mSockType socktype);
/*
* Set up a UDP server. Return the socket fd, or 0 on error.
*/
int
setup_udp_server(char *address, int port);
/*
* Given a listening udp socket, read a datagram and return it. The
* dgram char* must be supplied by the caller. It will be populated, and
* also returned, returning NULL on error.
*/
char *
read_dgram(int socketfd, char *dgram, size_t dgram_size);
/*
* Set up a TCP server. Return the socket fd, or 0 on error.
*/
int
setup_tcp_server(char *address, int port, int backlog);
/*
* Connect to a TCP server. Return the socket fd, or -1 on error.
*/
int
connect_tcp_client(const char *address, const char *port);
/*
* Connect to a unix domain socket as a stream. Return the socket fd, or -1 on error.
*/
int
connect_nix_streaming_client(const char *sockpath);
#ifdef __cplusplus
};
#endif
#endif