solve some send port bug

This commit is contained in:
gxt_kt 2024-12-05 15:05:35 +08:00
parent 5759f28daa
commit 2dea66ba11

View File

@ -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_;
}