Skip to content

Commit

Permalink
this should fix it
Browse files Browse the repository at this point in the history
  • Loading branch information
gafferongames committed Jul 18, 2016
1 parent 8efb6d7 commit 9fb62b8
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 34 deletions.
21 changes: 21 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@

Sunday July 17th, 2016
======================

Need to add an intensive logging mode to help track down what is going on one user's system.

They are only getting ~20 clients connecting to the server in profile.cpp, but the rest of the clients
are sending packets but seemingly not establishing connection. Weird.

Need logs to track down what is going on. It's really strange.

Added some basic logs here, looking good.

OK. no dice. Packets just not getting through.

Theory: on this particular version of windows the default socket buffers are just too small.

Bump up socket buffers to 1mb send and 1mb receive by default (users can specify if they want more or less, but good default...)

This should fix the issue.


Saturday July 16th, 2016
========================

Expand Down
9 changes: 0 additions & 9 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
DONE

Need to add an intensive logging mode to help track down what is going on one user's system.

They are only getting ~20 clients connecting to the server in profile.cpp, but the rest of the clients
are sending packets but seemingly not establishing connection. Weird.

Need logs to track down what is going on. It's really strange.

Added some basic logs here, looking good.

TODO

------------------
Expand Down
2 changes: 1 addition & 1 deletion profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#define SERVER 1
#define CLIENT 1
#define MATCHER 1
//#define QUIET 1
#define QUIET 1

#include "shared.h"
#include <signal.h>
Expand Down
4 changes: 2 additions & 2 deletions yojimbo_client_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ namespace yojimbo

if ( FindAddressAndClientId( address, connectToken.clientId ) >= 0 )
{
debug_printf( "client id already connected: %d\n", (int) connectToken.clientId );
debug_printf( "client id already connected: %" PRIx64 " (connection request)\n", connectToken.clientId );
m_counters[SERVER_COUNTER_CONNECT_TOKEN_CLIENT_ID_ALREADY_CONNECTED]++;
return;
}
Expand Down Expand Up @@ -1131,7 +1131,7 @@ namespace yojimbo
}
}

debug_printf( "client is already connected\n" );
debug_printf( "client is already connected: %" PRIx64 " (challenge response)\n", challengeToken.clientId );

return;
}
Expand Down
2 changes: 1 addition & 1 deletion yojimbo_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@

#endif // #if DEBUG

#define YOJIMBO_DEBUG_SPAM 1 // really spammy logs for debugging yojimbo
//#define YOJIMBO_DEBUG_SPAM 1

#endif // #ifndef YOJIMBO_CONFIG_H
37 changes: 18 additions & 19 deletions yojimbo_sockets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

namespace yojimbo
{
Socket::Socket( const Address & address )
Socket::Socket( const Address & address, int bufferSize )
{
assert( address.IsValid() );
assert( IsNetworkInitialized() );
Expand Down Expand Up @@ -102,6 +102,20 @@ namespace yojimbo
}
}

// increase socket send and receive buffer sizes

if ( setsockopt( m_socket, SOL_SOCKET, SO_RCVBUF, (char*)&bufferSize, sizeof(int) ) != 0 )
{
m_error = SOCKET_ERROR_SOCKOPT_RECVBUF_FAILED;
return;
}

if ( setsockopt( m_socket, SOL_SOCKET, SO_SNDBUF, (char*)&bufferSize, sizeof(int) ) != 0 )
{
m_error = SOCKET_ERROR_SOCKOPT_SNDBUF_FAILED;
return;
}

// bind to port

if ( address.GetType() == ADDRESS_IPV6 )
Expand Down Expand Up @@ -224,14 +238,6 @@ namespace yojimbo

bool result = false;

#if YOJIMBO_DEBUG_SPAM
char toString[MaxAddressLength];
char fromString[MaxAddressLength];
to.ToString( toString, MaxAddressLength );
m_address.ToString( fromString, MaxAddressLength );
debug_printf( "sending packet from %s to %s (%d bytes)\n", toString, fromString, packetBytes );
#endif // #if YOJIMBO_DEBUG_SPAM

if ( to.GetType() == ADDRESS_IPV6 )
{
sockaddr_in6 socket_address;
Expand Down Expand Up @@ -301,14 +307,6 @@ namespace yojimbo

const int bytesRead = result;

#if YOJIMBO_DEBUG_SPAM
char toString[MaxAddressLength];
char fromString[MaxAddressLength];
from.ToString( fromString, MaxAddressLength );
m_address.ToString( toString, MaxAddressLength );
debug_printf( "received packet from %s to %s (%d bytes)\n", fromString, toString, bytesRead );
#endif // #if YOJIMBO_DEBUG_SPAM

return bytesRead;
}

Expand All @@ -323,7 +321,8 @@ namespace yojimbo
uint32_t protocolId,
int maxPacketSize,
int sendQueueSize,
int receiveQueueSize )
int receiveQueueSize,
int bufferSize )
: BaseTransport( allocator,
packetFactory,
address,
Expand All @@ -332,7 +331,7 @@ namespace yojimbo
sendQueueSize,
receiveQueueSize )
{
m_socket = YOJIMBO_NEW( allocator, Socket, address );
m_socket = YOJIMBO_NEW( allocator, Socket, address, bufferSize );
}

SocketTransport::~SocketTransport()
Expand Down
7 changes: 5 additions & 2 deletions yojimbo_sockets.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ namespace yojimbo
SOCKET_ERROR_CREATE_FAILED,
SOCKET_ERROR_SET_NON_BLOCKING_FAILED,
SOCKET_ERROR_SOCKOPT_IPV6_ONLY_FAILED,
SOCKET_ERROR_SOCKOPT_RECVBUF_FAILED,
SOCKET_ERROR_SOCKOPT_SNDBUF_FAILED,
SOCKET_ERROR_BIND_IPV4_FAILED,
SOCKET_ERROR_BIND_IPV6_FAILED,
SOCKET_ERROR_GET_SOCKNAME_IPV4_FAILED,
Expand All @@ -62,7 +64,7 @@ namespace yojimbo
{
public:

explicit Socket( const Address & address );
explicit Socket( const Address & address, int bufferSize = 1024*1024 );

~Socket();

Expand Down Expand Up @@ -93,7 +95,8 @@ namespace yojimbo
uint32_t protocolId,
int maxPacketSize = 4 * 1024,
int sendQueueSize = 1024,
int receiveQueueSize = 1024 );
int receiveQueueSize = 1024,
int bufferSize = 1024*1024 );

~SocketTransport();

Expand Down

0 comments on commit 9fb62b8

Please sign in to comment.