From 31b6fc52f49449189e31e13626c392d4c576c833 Mon Sep 17 00:00:00 2001
From: wangzhengquan <wangzhengquan85@126.com>
Date: 星期五, 05 二月 2021 18:16:58 +0800
Subject: [PATCH] update
---
test_socket/bus_test.cpp | 29 ++++++++++-------------------
1 files changed, 10 insertions(+), 19 deletions(-)
diff --git a/test_socket/bus_test.cpp b/test_socket/bus_test.cpp
index f84ad52..8d630b6 100644
--- a/test_socket/bus_test.cpp
+++ b/test_socket/bus_test.cpp
@@ -4,10 +4,11 @@
#include "usg_common.h"
#include "mm.h"
#include "logger_factory.h"
+
#include "bus_error.h"
static Logger *logger = LoggerFactory::getLogger();
-
+
BusServerSocket * server_socket;
void sigint_handler(int sig) {
@@ -23,19 +24,20 @@
}
-void *run_recv2(void *skptr) {
+void *run_recv(void *skptr) {
pthread_detach(pthread_self());
void *recvbuf;
int size;
int key;
+
int rv;
ShmModSocket *sk = (ShmModSocket *)skptr;
-printf("run_recv\n");
struct timespec timeout = {2, 0};
while (true) {
printf("run_recv before\n");
- rv = sk->recvfrom_timeout( &recvbuf, &size, &key, &timeout);
+ // rv = sk->recvfrom_timeout( &recvbuf, &size, &key, &timeout);
+ rv = sk->recvfrom( &recvbuf, &size, &key);
if(rv == 0) {
printf("鏀跺埌璁㈤槄娑堟伅:%s\n", recvbuf);
free(recvbuf);
@@ -48,22 +50,11 @@
}
-void *run_recv(void *skptr) {
- while(true) {
- logger->debug("================run_recv\n");
- sleep(1);
- }
-}
-
-void client2(int key) {
- ShmModSocket *sk = new ShmModSocket();
- run_recv((void *)sk);
-}
-
void client(int key) {
ShmModSocket *sk = new ShmModSocket();
pthread_t tid;
+
int size;
@@ -72,14 +63,14 @@
char content[512];
long i = 0;
+
pthread_create(&tid, NULL, run_recv, (void *)sk);
while (true) {
//printf("Usage: pub <topic> [content] or sub <topic>\n");
printf("Can I help you? sub, pub, desub or quit %d\n", i++);
- // sleep(100);
- scanf("%s", action);
-
+ // scanf("%s", action);
+ std::cin >> action;
if(strcmp(action, "sub") == 0) {
printf("Please input topic!\n");
scanf("%s", topic);
--
Gitblit v1.8.0