forked from IQgaSagatteikuKanji/nnfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
libnnfs_socket.h
39 lines (28 loc) · 1.09 KB
/
libnnfs_socket.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
#pragma once
#include "libnnfs_proto.h"
//struct that hides details
struct nnfs_context{
int socket;
};
//inits the socket
void nnfs_init_context(struct nnfs_context *);
//connects to a nnfs server
int nnfs_connect(struct nnfs_context *, const char *ip, const char*port);
//binds socket to the address and port
int nnfs_bind(struct nnfs_context *, const char *ip, const char *port);
//starts listening for clients
int nnfs_listen(struct nnfs_context *, uint32_t max_clients);
//accepts connection returning client information
int nnfs_accept(struct nnfs_context *server, struct nnfs_context *client);
//send a message to a remote server
//returns how many bytes are sent
int nnfs_send(struct nnfs_context *, struct MSG *);
//receive a message from a remote server
//returns how many bytes are received
int nnfs_receive(struct nnfs_context *, struct MSG *);
//shutdowns a nnfs_connection
//returns 0 on success
int nnfs_shutdown(struct nnfs_context *);
//closes a nnfs_socket
//may not free the socket adress for about 4 minutes, refer to the socket documentation
int nnfs_close(struct nnfs_context *);