Skip to content

Commit fd7505d

Browse files
committed
Refactor TCP socket connection calls in tests and implementation
- Replaced instances of `TCPSocket::setup()` with `TCPSocket::connect()` across multiple test files and the dashboard client implementation to standardize connection handling. - Updated connection logic to improve clarity and consistency in socket management.
1 parent af01c3f commit fd7505d

7 files changed

Lines changed: 13 additions & 8 deletions

src/ur/dashboard_client_implementation_g5.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ bool DashboardClientImplG5::connect(const size_t max_num_tries, const std::chron
220220
TCPSocket::setReceiveTimeout(tv);
221221
try
222222
{
223-
if (TCPSocket::setup(host_, port_, max_num_tries, reconnection_time))
223+
if (TCPSocket::connect(host_, port_, max_num_tries, reconnection_time))
224224
{
225225
URCL_LOG_INFO("%s", read().c_str());
226226
ret_val = true;

tests/test_reverse_interface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class ReverseInterfaceTest : public ::testing::Test
7676
Client(const int& port)
7777
{
7878
std::string host = "127.0.0.1";
79-
TCPSocket::setup(host, port);
79+
TCPSocket::connect(host, port);
8080
timeval tv;
8181
tv.tv_sec = 1;
8282
tv.tv_usec = 0;

tests/test_script_command_interface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ScriptCommandInterfaceTest : public ::testing::Test
4949
Client(const int& port)
5050
{
5151
std::string host = "127.0.0.1";
52-
TCPSocket::setup(host, port);
52+
TCPSocket::connect(host, port);
5353
timeval tv;
5454
tv.tv_sec = 1;
5555
tv.tv_usec = 0;

tests/test_script_sender.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ScriptSenderTest : public ::testing::Test
4343
Client(const int& port)
4444
{
4545
std::string host = "127.0.0.1";
46-
TCPSocket::setup(host, port);
46+
TCPSocket::connect(host, port);
4747
timeval tv;
4848
tv.tv_sec = 1;
4949
tv.tv_usec = 0;

tests/test_tcp_server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class TCPServerTest : public ::testing::Test
5858
Client(const int& port)
5959
{
6060
std::string host = "127.0.0.1";
61-
TCPSocket::setup(host, port);
61+
TCPSocket::connect(host, port);
6262
}
6363

6464
void send(const std::string& text)

tests/test_tcp_socket.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ class TCPSocketTest : public ::testing::Test
6969
bool setup(const size_t max_num_tries = 0,
7070
const std::chrono::milliseconds reconnection_time = std::chrono::seconds(10))
7171
{
72-
return TCPSocket::setup(ip_, port_, max_num_tries, reconnection_time);
72+
return TCPSocket::connect(ip_, port_, max_num_tries, reconnection_time);
73+
}
74+
75+
void disconnect()
76+
{
77+
TCPSocket::disconnect();
7378
}
7479

7580
void setupClientBeforeServer(const size_t max_num_tries = 0,
@@ -107,7 +112,7 @@ class TCPSocketTest : public ::testing::Test
107112
std::chrono::milliseconds reconnection_time = std::chrono::seconds(10))
108113
{
109114
std::string ip = "127.0.0.1";
110-
TCPSocket::setup(ip, port, max_num_tries, reconnection_time);
115+
TCPSocket::connect(ip, port, max_num_tries, reconnection_time);
111116
done_setting_up_client_ = true;
112117
}
113118
};

tests/test_trajectory_point_interface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class TrajectoryPointInterfaceTest : public ::testing::Test
7979
Client(const int& port)
8080
{
8181
std::string host = "127.0.0.1";
82-
TCPSocket::setup(host, port);
82+
TCPSocket::connect(host, port);
8383
timeval tv;
8484
tv.tv_sec = 1;
8585
tv.tv_usec = 0;

0 commit comments

Comments
 (0)