-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathNetlib.h
50 lines (41 loc) · 1.26 KB
/
Netlib.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
#ifndef __NETLIB_H__
#define __NETLIB_H__
#include "Ostype.h"
#define NETLIB_OPT_SET_CALLBACK 1
#define NETLIB_OPT_SET_CALLBACK_DATA 2
#define NETLIB_OPT_GET_REMOTE_IP 3
#define NETLIB_OPT_GET_REMOTE_PORT 4
#define NETLIB_OPT_GET_LOCAL_IP 5
#define NETLIB_OPT_GET_LOCAL_PORT 6
#define NETLIB_OPT_SET_SEND_BUF_SIZE 7
#define NETLIB_OPT_SET_RECV_BUF_SIZE 8
#define NETLIB_MAX_SOCKET_BUF_SIZE (128*1024)
#ifdef __cplusplus
extern "C" {
#endif
int netlib_init();
int netlib_destroy();
int netlib_listen(
const char* server_ip,
uint16_t port,
callback_t callback,
void* callback_data);
net_handle_t netlib_connect(
const char* server_ip,
uint16_t port,
callback_t callback,
void* callback_data);
int netlib_send(net_handle_t handle, void* buf, int len);
int netlib_recv(net_handle_t handle, void* buf, int len);
int netlib_close(net_handle_t handle);
int netlib_option(net_handle_t handle, int opt, void* optval);
int netlib_register_timer(callback_t callback, void* user_data,uint64_t interval);
int netlib_delete_timer(callback_t callback, void* user_data);
int netlib_add_loop(callback_t callback, void* user_data);
void netlib_eventloop(uint32_t wait_timeout = 100);
void netlib_stop_event();
bool netlib_is_running();
#ifdef __cplusplus
}
#endif
#endif