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
| #ifndef __BASIC_SHM_SOCKET_H__
| #define __BASIC_SHM_SOCKET_H__
|
| #include "usg_common.h"
| #ifdef __cplusplus
| extern "C" {
| #endif
|
| enum shm_mod_t
| {
| PULL_PUSH = 1,
| REQ_REP = 2,
| PAIR = 3,
| PUB_SUB = 4,
| SURVEY = 5,
| BUS = 6
|
| };
|
|
| /**
| * 初始化共享内存
| * @size 共享内存大小, 单位M
| *
| */
| void shm_init(int size);
|
| /**
| * 销毁共享内存
| * 整个进程退出时需要执行这个方法,该方法首先会检查是否还有其他进程在使用该共享内存,如果还有其他进程在使用就只是detach,如果没有其他进程在使用则销毁整块内存。
| */
| void shm_destroy();
|
| /**
| * 释放recv方法分配的buf
| */
| void shm_free(void *buf);
|
| void *shm_open_socket(int mod);
|
|
| int shm_close_socket(void *socket) ;
|
|
| int shm_bind(void* socket, int port) ;
|
| int shm_listen(void* socket) ;
|
| int shm_connect(void* socket, int port);
|
| int shm_send(void *socket, void *buf, int size) ;
|
| int shm_recv(void* socket, void **buf, int *size) ;
|
|
|
| #ifdef __cplusplus
| }
| #endif
|
| #endif
|
|