#ifndef __shm_stream_mod_socket_SOCKET_H__
|
#define __shm_stream_mod_socket_SOCKET_H__
|
|
|
|
|
enum socket_mod_t
|
{
|
PULL_PUSH = 1,
|
REQ_REP = 2,
|
PAIR = 3,
|
PUB_SUB = 4,
|
SURVEY = 5,
|
BUS = 6
|
|
};
|
|
/**
|
* 创建socket
|
* @return socket地址
|
*/
|
void *shm_stream_mod_socket_open(int mod);
|
|
/**
|
* 关闭socket
|
* @return 0 成功, 其他值 失败的错误码
|
*/
|
int shm_stream_mod_socket_close(void * _socket);
|
|
/**
|
* 绑定端口到socket, 如果不绑定则系统自动分配一个
|
* @return 0 成功, 其他值 失败的错误码
|
*/
|
int shm_stream_mod_socket_bind(void * _socket, int key);
|
|
|
/**
|
* 服务端开启连接监听
|
* @return 0 成功, 其他值 失败的错误码
|
*/
|
int shm_stream_mod_socket_listen(void * _socket);
|
|
/**
|
* 客户端发起连接请求
|
*/
|
int shm_stream_mod_socket_connect(void * _socket, int key);
|
|
/**
|
* 发送信息
|
* @return 0 成功, 其他值 失败的错误码
|
*/
|
int shm_stream_mod_socket_send(void * _socket, const void *buf, const int size);
|
|
/**
|
* 接收信息
|
* @return 0 成功, 其他值 失败的错误码
|
*/
|
int shm_stream_mod_socket_recv(void * _socket, void **buf, int *size) ;
|
|
/**
|
* 释放存储接收信息的buf
|
*/
|
void shm_stream_mod_socket_free(void *buf);
|
|
|
/**
|
* 获取soket端口号
|
*/
|
int shm_stream_mod_socket_get_key(void * _socket);
|
|
|
|
#endif
|