| | |
| | | function server() { |
| | | |
| | | |
| | | # 开启bus |
| | | ./test_net_mod_socket --fun="start_bus_server" & server_pid=$! && echo "pid: ${server_pid}" |
| | | # 开启网络转发代理 |
| | | ./test_net_mod_socket --fun="start_net_proxy" --port=5000 & server_pid=$! && echo "pid: ${server_pid}" |
| | | |
| | | # 打开请求应答的server |
| | | ./dgram_mod_req_rep server 11 & server_pid=$! && echo ${server_pid} |
| | | |
| | | |
| | | # 开启bus |
| | | ./dgram_mod_bus server 8 & server_pid=$! && echo ${server_pid} |
| | | |
| | | # 开启网络server |
| | | ./test_net_mod_socket server 5000 & server_pid=$! && echo ${server_pid} |
| | | |
| | | # 打开请求应答测试的接受端 |
| | | ./test_net_mod_socket --fun="start_reply" --key=100 & server_pid=$! && echo "pid: ${server_pid}" |
| | | } |
| | | |
| | | function client() { |
| | | ./test_net_mod_socket client 5000 |
| | | |
| | | # ./test_net_mod_socket --fun="start_net_client" \ |
| | | # --sendlist="192.168.5.10:5000:11, 192.168.5.22:5000:11, 192.168.20.104:5000:11" \ |
| | | # --publist="192.168.5.10:5000:8, 192.168.5.22:5000:8, 192.168.20.104:5000:8" |
| | | |
| | | |
| | | ./test_net_mod_socket --fun="start_net_client" \ |
| | | --sendlist="localhost:5000:100" \ |
| | | --publist="localhost:5000" |
| | | |
| | | |
| | | } |
| | | |
| | | function msend() { |
| | | ./test_net_mod_socket --fun="test_net_sendandrecv_threads" \ |
| | | --sendlist="localhost:5000:100, localhost:5000:100" |
| | | |
| | | } |
| | | |
| | | function mpub() { |
| | | ./test_net_mod_socket --fun="test_net_pub_threads" \ |
| | | --publist="localhost:5000, localhost:5000" |
| | | |
| | | } |
| | | |
| | | function close() { |
| | | ps -ef | grep -e "dgram_mod_req_rep" -e "net_mod_socket" -e "dgram_mod_bus" | awk '{print $2}' | xargs -i kill -9 {} |
| | | ps -ef | grep -e "test_net_mod_socket" -e "net_mod_socket"| awk '{print $2}' | xargs -i kill -9 {} |
| | | ipcrm -a |
| | | } |
| | | |
| | |
| | | case ${1} in |
| | | "server") |
| | | close |
| | | sleep 2 |
| | | server |
| | | ;; |
| | | "client") |
| | | client |
| | | ;; |
| | | "msend") |
| | | msend |
| | | ;; |
| | | "mpub") |
| | | mpub |
| | | ;; |
| | | "close") |
| | | close |
| | | ;; |
| | | "") |
| | | close |
| | | sleep 2 |
| | | server |
| | | client |
| | | ;; |
| | | |
| | | *) |
| | | echo "error input" |
| | | echo "argument input error" |
| | | exit 1 |
| | | ;; |
| | | esac |