| | |
| | | * 绑定端口到socket, 如果不绑定则系统自动分配一个 |
| | | * @return 0 成功, 其他值 失败的错误码 |
| | | */ |
| | | int NetModSocket::bind(int port) { |
| | | return shmModSocket.bind(port); |
| | | int NetModSocket::bind(int key) { |
| | | return shmModSocket.bind(key); |
| | | } |
| | | |
| | | /** |
| | | * 强制绑定端口到socket, 适用于程序非正常关闭的情况下,重启程序绑定原来还没释放的key |
| | | * @return 0 成功, 其他值 失败的错误码 |
| | | */ |
| | | int NetModSocket::force_bind( int port) { |
| | | return shmModSocket.force_bind(port); |
| | | int NetModSocket::force_bind( int key) { |
| | | return shmModSocket.force_bind(key); |
| | | } |
| | | |
| | | int NetModSocket::sendandrecv(net_node_t *node_arr, int arrlen, void *send_buf, int send_size, |
| | |
| | | |
| | | /** |
| | | * 发送信息 |
| | | * @port 发送给谁 |
| | | * @key 发送给谁 |
| | | * @return 0 成功, 其他值 失败的错误码 |
| | | */ |
| | | int NetModSocket::sendto(const void *buf, const int size, const int port){ |
| | | return shmModSocket.sendto(buf, size,port); |
| | | int NetModSocket::sendto(const void *buf, const int size, const int key){ |
| | | return shmModSocket.sendto(buf, size, key); |
| | | } |
| | | |
| | | // 发送信息超时返回。 @sec 秒 , @nsec 纳秒 |
| | | int NetModSocket::sendto_timeout(const void *buf, const int size, const int port, int sec, int nsec){ |
| | | int NetModSocket::sendto_timeout(const void *buf, const int size, const int key, int sec, int nsec){ |
| | | struct timespec timeout = {sec, nsec}; |
| | | return shmModSocket.sendto_timeout(buf, size, port, &timeout); |
| | | return shmModSocket.sendto_timeout(buf, size, key, &timeout); |
| | | } |
| | | |
| | | // 发送信息立刻返回。 |
| | | int NetModSocket::sendto_nowait(const void *buf, const int size, const int port){ |
| | | return shmModSocket.sendto_nowait(buf, size,port); |
| | | int NetModSocket::sendto_nowait(const void *buf, const int size, const int key){ |
| | | return shmModSocket.sendto_nowait(buf, size, key); |
| | | } |
| | | |
| | | /** |
| | | * 接收信息 |
| | | * @port 从谁哪里收到的信息 |
| | | * @key 从谁哪里收到的信息 |
| | | * @return 0 成功, 其他值 失败的错误码 |
| | | */ |
| | | int NetModSocket::recvfrom(void **buf, int *size, int *port) { |
| | | return shmModSocket.recvfrom(buf, size, port); |
| | | int NetModSocket::recvfrom(void **buf, int *size, int *key) { |
| | | return shmModSocket.recvfrom(buf, size, key); |
| | | } |
| | | // 接受信息超时返回。 @sec 秒 , @nsec 纳秒 |
| | | int NetModSocket::recvfrom_timeout(void **buf, int *size, int *port, int sec, int nsec){ |
| | | int NetModSocket::recvfrom_timeout(void **buf, int *size, int *key, int sec, int nsec){ |
| | | struct timespec timeout = {sec, nsec}; |
| | | return shmModSocket.recvfrom_timeout(buf, size, port, &timeout); |
| | | return shmModSocket.recvfrom_timeout(buf, size, key, &timeout); |
| | | } |
| | | |
| | | int NetModSocket::recvfrom_nowait(void **buf, int *size, int *port){ |
| | | return shmModSocket.recvfrom_nowait(buf, size, port); |
| | | int NetModSocket::recvfrom_nowait(void **buf, int *size, int *key){ |
| | | return shmModSocket.recvfrom_nowait(buf, size, key); |
| | | } |
| | | |
| | | /** |
| | | * 发送请求信息并等待接收应答 |
| | | * @port 发送给谁 |
| | | * @key 发送给谁 |
| | | * @return 0 成功, 其他值 失败的错误码 |
| | | */ |
| | | int NetModSocket::sendandrecv( const void *send_buf, const int send_size, const int port, void **recv_buf, int *recv_size){ |
| | | return shmModSocket.sendandrecv(send_buf, send_size, port, recv_buf, recv_size); |
| | | int NetModSocket::sendandrecv( const void *send_buf, const int send_size, const int key, void **recv_buf, int *recv_size){ |
| | | return shmModSocket.sendandrecv(send_buf, send_size, key, recv_buf, recv_size); |
| | | } |
| | | // 超时返回。 @sec 秒 , @nsec 纳秒 |
| | | int NetModSocket::sendandrecv_timeout( const void *send_buf, const int send_size, const int port, void **recv_buf, int *recv_size, int sec, int nsec){ |
| | | int NetModSocket::sendandrecv_timeout( const void *send_buf, const int send_size, const int key, void **recv_buf, int *recv_size, int sec, int nsec){ |
| | | struct timespec timeout = {sec, nsec}; |
| | | return shmModSocket.sendandrecv_timeout(send_buf, send_size, port, recv_buf, recv_size, &timeout); |
| | | return shmModSocket.sendandrecv_timeout(send_buf, send_size, key, recv_buf, recv_size, &timeout); |
| | | } |
| | | int NetModSocket::sendandrecv_nowait( const void *send_buf, const int send_size, const int port, void **recv_buf, int *recv_size) { |
| | | return shmModSocket.sendandrecv_nowait(send_buf, send_size, port, recv_buf, recv_size); |
| | | int NetModSocket::sendandrecv_nowait( const void *send_buf, const int send_size, const int key, void **recv_buf, int *recv_size) { |
| | | return shmModSocket.sendandrecv_nowait(send_buf, send_size, key, recv_buf, recv_size); |
| | | } |
| | | |
| | | |
| | |
| | | * 订阅指定主题 |
| | | * @topic 主题 |
| | | * @size 主题长度 |
| | | * @port 总线端口 |
| | | * @key 总线端口 |
| | | */ |
| | | int NetModSocket::sub( void *topic, int size, int port){ |
| | | return shmModSocket.sub((char *)topic, size, port); |
| | | int NetModSocket::sub( void *topic, int size, int key){ |
| | | return shmModSocket.sub((char *)topic, size, key); |
| | | } |
| | | // 超时返回。 @sec 秒 , @nsec 纳秒 |
| | | int NetModSocket::sub_timeout( void *topic, int size, int port, int sec, int nsec){ |
| | | int NetModSocket::sub_timeout( void *topic, int size, int key, int sec, int nsec){ |
| | | struct timespec timeout = {sec, nsec}; |
| | | return shmModSocket.sub_timeout((char *)topic, size, port, &timeout); |
| | | return shmModSocket.sub_timeout((char *)topic, size, key, &timeout); |
| | | } |
| | | int NetModSocket::sub_nowait( void *topic, int size, int port){ |
| | | return shmModSocket.sub_nowait((char *)topic, size, port); |
| | | int NetModSocket::sub_nowait( void *topic, int size, int key){ |
| | | return shmModSocket.sub_nowait((char *)topic, size, key); |
| | | } |
| | | |
| | | |
| | |
| | | * 取消订阅指定主题 |
| | | * @topic 主题 |
| | | * @size 主题长度 |
| | | * @port 总线端口 |
| | | * @key 总线端口 |
| | | */ |
| | | int NetModSocket::desub( void *topic, int size, int port){ |
| | | return shmModSocket.desub((char *)topic, size, port); |
| | | int NetModSocket::desub( void *topic, int size, int key){ |
| | | return shmModSocket.desub((char *)topic, size, key); |
| | | } |
| | | // 超时返回。 @sec 秒 , @nsec 纳秒 |
| | | int NetModSocket::desub_timeout( void *topic, int size, int port, int sec, int nsec){ |
| | | int NetModSocket::desub_timeout( void *topic, int size, int key, int sec, int nsec){ |
| | | struct timespec timeout = {sec, nsec}; |
| | | return shmModSocket.desub_timeout((char *)topic, size, port, &timeout); |
| | | return shmModSocket.desub_timeout((char *)topic, size, key, &timeout); |
| | | } |
| | | int NetModSocket::desub_nowait( void *topic, int size, int port){ |
| | | return shmModSocket.desub_nowait((char *)topic, size, port); |
| | | int NetModSocket::desub_nowait( void *topic, int size, int key){ |
| | | return shmModSocket.desub_nowait((char *)topic, size, key); |
| | | } |
| | | |
| | | |
| | |
| | | * 发布主题 |
| | | * @topic 主题 |
| | | * @content 主题内容 |
| | | * @port 总线端口 |
| | | * @key 总线端口 |
| | | */ |
| | | int NetModSocket::pub( char *topic, int topic_size, void *content, int content_size, int port){ |
| | | return shmModSocket.pub(topic, topic_size, content, content_size, port); |
| | | int NetModSocket::pub( char *topic, int topic_size, void *content, int content_size, int key){ |
| | | return shmModSocket.pub(topic, topic_size, content, content_size, key); |
| | | } |
| | | // 超时返回。 @sec 秒 , @nsec 纳秒 |
| | | int NetModSocket::pub_timeout( char *topic, int topic_size, void *content, int content_size, int port, int sec, int nsec){ |
| | | int NetModSocket::pub_timeout( char *topic, int topic_size, void *content, int content_size, int key, int sec, int nsec){ |
| | | struct timespec timeout = {sec, nsec}; |
| | | return shmModSocket.pub_timeout(topic, topic_size, content, content_size, port, &timeout); |
| | | return shmModSocket.pub_timeout(topic, topic_size, content, content_size, key, &timeout); |
| | | } |
| | | int NetModSocket::pub_nowait( char *topic, int topic_size, void *content, int content_size, int port){ |
| | | return shmModSocket.pub_nowait(topic, topic_size, content, content_size, port); |
| | | int NetModSocket::pub_nowait( char *topic, int topic_size, void *content, int content_size, int key){ |
| | | return shmModSocket.pub_nowait(topic, topic_size, content, content_size, key); |
| | | } |
| | | |
| | | |