Skip to content

Commit

Permalink
Add tcp_client test
Browse files Browse the repository at this point in the history
  • Loading branch information
idzm committed Nov 13, 2024
1 parent 3766d09 commit 6dededc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 1 addition & 4 deletions PAC/win/w_tcp_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,7 @@ int win_tcp_client::AsyncSend( unsigned int bytestosend )
async_result = AR_BUSY;
async_bytes_to_send = bytestosend;

auto connectionState = checkConnection();

if ( !connectionState ) return 0;

if ( !checkConnection() ) return 0;

int res = send( socket_number, buff, bytestosend, 0 );
if ( res == SOCKET_ERROR )
Expand Down
14 changes: 14 additions & 0 deletions test/tcp_client_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,17 @@ TEST( tcp_client, Connect )
// Should fail - timeout - no G_CMMCTR on such port.
EXPECT_EQ( 0, cl.Connect() );
}


TEST( tcp_client, AsyncSend )
{
#ifdef WIN_OS
win_tcp_client cl( "127.0.0.1", 10000 + 1, 1, 1, 256, 0 );
cl.InitLib();
#else
linux_tcp_client cl( "127.0.0.1", 10000 + 1, 1, 1, 256, 0 );
#endif // WIN_OS

// Should fail - timeout - no G_CMMCTR on such port.
EXPECT_EQ( 0, cl.AsyncSend( 100 ) );
}

0 comments on commit 6dededc

Please sign in to comment.