From 2dea66ba11910f21d5b357547225e8a3649d2fe3 Mon Sep 17 00:00:00 2001 From: gxt_kt Date: Thu, 5 Dec 2024 15:05:35 +0800 Subject: [PATCH] solve some send port bug --- src/send_mulport.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/send_mulport.cc b/src/send_mulport.cc index 09d0013..9c44852 100644 --- a/src/send_mulport.cc +++ b/src/send_mulport.cc @@ -53,22 +53,30 @@ class Client { } void Send(const T &val) { - clis_.at(cnt_port_)->Send(&val, sizeof(T)); + int send_port = cnt_port_; + send_port = send_port % all_ports_n_; + clis_.at(send_port)->Send((char *)&val, sizeof(T)); cnt_port_++; cnt_port_ = cnt_port_ % all_ports_n_; } void Send(const std::string &str) { - clis_.at(cnt_port_)->Send(str); + int send_port = cnt_port_; + send_port = send_port % all_ports_n_; + clis_.at(send_port)->Send(str); cnt_port_++; cnt_port_ = cnt_port_ % all_ports_n_; } void Send(const char *str, size_t size) { - clis_.at(cnt_port_)->Send(str, size); + int send_port = cnt_port_; + send_port = send_port % all_ports_n_; + clis_.at(send_port)->Send(str, size); cnt_port_++; cnt_port_ = cnt_port_ % all_ports_n_; } void Send(const char *str) { - clis_.at(cnt_port_)->Send(str); + int send_port = cnt_port_; + send_port = send_port % all_ports_n_; + clis_.at(send_port)->Send(str); cnt_port_++; cnt_port_ = cnt_port_ % all_ports_n_; }