-
Notifications
You must be signed in to change notification settings - Fork 2
/
mcast.h
executable file
·72 lines (56 loc) · 1.61 KB
/
mcast.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
*============================================================
* @file mcast.h
* @brief Define the interfaces to send multicast datagram
*
* compiler gcc4.1.2
* platform Linux
*
* copyright: TaoMee, Inc. ShangHai CN. All rights reserved.
*
*============================================================
*/
#ifndef ASYNC_SERVER_MCAST_H_
#define ASYNC_SERVER_MCAST_H_
#include <time.h>
#ifdef __cplusplus
extern "C" {
#endif
enum {
mcast_notify_addr = 0,
mcast_reload_text = 1
};
enum {
addr_mcast_1st_pkg = 1,
addr_mcast_syn_pkg = 2
};
struct addr_node {
uint32_t svr_id;
char ip[16];
unsigned short port;
time_t last_syn_tm;
};
typedef struct addr_node addr_node_t;
extern time_t next_syn_addr_tm;
extern time_t next_del_addrs_tm;
int create_addr_mcast_socket();
void send_addr_mcast_pkg(uint32_t pkg_type);
addr_node_t* get_service_ipport(const char* service, unsigned int svr_id);
void del_expired_addrs();
void asyncserv_proc_mcast_pkg(void* data, int len);
//------------------------------------------------------------
int asynsvr_create_mcast_socket();
/**
* @brief Send out a mcast datagram to the specified `mcast_ip` and `mcast_port`.
* Note, length of the data should be no longer than 8192.
*
* @param const void* data, data to send.
* @param int len, length of `data`.
*
* @return int, number of characters sent on success, -1 on error
*/
int send_mcast_pkg(const void* data, int len);
#ifdef __cplusplus
} // end of extern "C"
#endif
#endif // ASYNC_SERVER_MCAST_H_