summaryrefslogtreecommitdiff
path: root/csgo-loader/csgo-client/Networking
diff options
context:
space:
mode:
Diffstat (limited to 'csgo-loader/csgo-client/Networking')
-rw-r--r--csgo-loader/csgo-client/Networking/TCPClient.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/csgo-loader/csgo-client/Networking/TCPClient.cpp b/csgo-loader/csgo-client/Networking/TCPClient.cpp
index aeb2dfc..11d4677 100644
--- a/csgo-loader/csgo-client/Networking/TCPClient.cpp
+++ b/csgo-loader/csgo-client/Networking/TCPClient.cpp
@@ -12,7 +12,7 @@ namespace Networking
int32_t Result = send(m_Socket, (char *)Bytes.data(), (int)Bytes.size(), 0);
if(Result == -1)
- INFO_ASSERT("[000F:00002B00] Server closed the connection suddenly.");
+ INFO_ASSERT("[000F:00002B00] Server closed the connection unexpectedly.");
}
ByteArray TCPClient::ReceiveRawBytes()
@@ -32,7 +32,7 @@ namespace Networking
// Emplace all received bytes.
for(int n = 0; n < Received; ++n)
{
- ReceivedBytes.emplace_back(RecvBuffer[n]);
+ ReceivedBytes.push_back(RecvBuffer[n]);
}
// No more bytes left to receive.
@@ -77,16 +77,12 @@ namespace Networking
// Set up client context.
m_Context.sin_addr.s_addr = ServerAddress;
- m_Context.sin_family = AF_INET;
- m_Context.sin_port = htons(ServerPort);
-
- // Attempt connection.
- if(connect(m_Socket, (sockaddr *)&m_Context, sizeof m_Context))
- return false;
-
+ m_Context.sin_family = AF_INET;
+ m_Context.sin_port = htons(ServerPort);
+
// Allow the socket to time-out.
timeval timeout;
- timeout.tv_sec = 30;
+ timeout.tv_sec = 5;
if(setsockopt(m_Socket, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof timeout) == INVALID_SOCKET)
return false;
@@ -94,6 +90,10 @@ namespace Networking
if(setsockopt(m_Socket, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof timeout) == INVALID_SOCKET)
return false;
+ // Attempt connection.
+ if(connect(m_Socket, (sockaddr *)&m_Context, sizeof m_Context))
+ return false;
+
// Initialise encryption wrapper.
ByteArray EncryptionKey = ReceiveRawBytes();
m_Encryption.Start(EncryptionKey);