mirror of
https://github.com/glest/glest-source.git
synced 2025-08-14 20:34:01 +02:00
- added some special ways to configure how sockets work on a system for testing
This commit is contained in:
@@ -2595,6 +2595,19 @@ int glestMain(int argc, char** argv) {
|
|||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
setupGameItemPaths(argc, argv, &config);
|
setupGameItemPaths(argc, argv, &config);
|
||||||
|
|
||||||
|
Socket::disableNagle = config.getBool("DisableNagle","false");
|
||||||
|
if(Socket::disableNagle) {
|
||||||
|
printf("*WARNING users wants to disable the socket nagle algorithm.\n");
|
||||||
|
}
|
||||||
|
Socket::DEFAULT_SOCKET_SENDBUF_SIZE = config.getInt("DefaultSocketSendBufferSize",intToStr(Socket::DEFAULT_SOCKET_SENDBUF_SIZE).c_str());
|
||||||
|
if(Socket::DEFAULT_SOCKET_SENDBUF_SIZE >= 0) {
|
||||||
|
printf("*WARNING users wants to set default socket send buffer size to: %d\n",Socket::DEFAULT_SOCKET_SENDBUF_SIZE);
|
||||||
|
}
|
||||||
|
Socket::DEFAULT_SOCKET_RECVBUF_SIZE = config.getInt("DefaultSocketReceiveBufferSize",intToStr(Socket::DEFAULT_SOCKET_RECVBUF_SIZE).c_str());
|
||||||
|
if(Socket::DEFAULT_SOCKET_RECVBUF_SIZE >= 0) {
|
||||||
|
printf("*WARNING users wants to set default socket receive buffer size to: %d\n",Socket::DEFAULT_SOCKET_RECVBUF_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
shutdownFadeSoundMilliseconds = config.getInt("ShutdownFadeSoundMilliseconds",intToStr(shutdownFadeSoundMilliseconds).c_str());
|
shutdownFadeSoundMilliseconds = config.getInt("ShutdownFadeSoundMilliseconds",intToStr(shutdownFadeSoundMilliseconds).c_str());
|
||||||
|
|
||||||
string userData = config.getString("UserData_Root","");
|
string userData = config.getString("UserData_Root","");
|
||||||
|
@@ -130,6 +130,10 @@ public:
|
|||||||
Socket();
|
Socket();
|
||||||
virtual ~Socket();
|
virtual ~Socket();
|
||||||
|
|
||||||
|
static bool disableNagle;
|
||||||
|
static int DEFAULT_SOCKET_SENDBUF_SIZE;
|
||||||
|
static int DEFAULT_SOCKET_RECVBUF_SIZE;
|
||||||
|
|
||||||
//virtual void simpleTask(BaseThread *callingThread);
|
//virtual void simpleTask(BaseThread *callingThread);
|
||||||
|
|
||||||
static int getBroadCastPort() { return broadcast_portno; }
|
static int getBroadCastPort() { return broadcast_portno; }
|
||||||
|
@@ -47,6 +47,7 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <netinet/tcp.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@@ -62,6 +63,10 @@ using namespace Shared::Util;
|
|||||||
|
|
||||||
namespace Shared{ namespace Platform{
|
namespace Shared{ namespace Platform{
|
||||||
|
|
||||||
|
bool Socket::disableNagle = false;
|
||||||
|
int Socket::DEFAULT_SOCKET_SENDBUF_SIZE = -1;
|
||||||
|
int Socket::DEFAULT_SOCKET_RECVBUF_SIZE = -1;
|
||||||
|
|
||||||
int Socket::broadcast_portno = 61357;
|
int Socket::broadcast_portno = 61357;
|
||||||
int ServerSocket::ftpServerPort = 61358;
|
int ServerSocket::ftpServerPort = 61358;
|
||||||
int ServerSocket::maxPlayerCount = -1;
|
int ServerSocket::maxPlayerCount = -1;
|
||||||
@@ -816,6 +821,42 @@ Socket::Socket() {
|
|||||||
int set = 1;
|
int set = 1;
|
||||||
setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int));
|
setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Disable the Nagle (TCP No Delay) algorithm */
|
||||||
|
if(Socket::disableNagle == true) {
|
||||||
|
int flag = 1;
|
||||||
|
int ret = setsockopt( sock, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(flag) );
|
||||||
|
if (ret == -1) {
|
||||||
|
printf("Couldn't setsockopt(TCP_NODELAY)\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Socket::DEFAULT_SOCKET_SENDBUF_SIZE >= 0) {
|
||||||
|
int bufsize = 0;
|
||||||
|
socklen_t optlen = sizeof(bufsize);
|
||||||
|
|
||||||
|
int ret = getsockopt(sock, SOL_SOCKET, SO_SNDBUF, &bufsize, &optlen);
|
||||||
|
printf("Original setsockopt(SO_SNDBUF) = [%d] new will be [%d]\n",bufsize,Socket::DEFAULT_SOCKET_SENDBUF_SIZE);
|
||||||
|
|
||||||
|
ret = setsockopt( sock, SOL_SOCKET, SO_SNDBUF, (char *) &Socket::DEFAULT_SOCKET_SENDBUF_SIZE, sizeof( int ) );
|
||||||
|
if (ret == -1) {
|
||||||
|
printf("Couldn't setsockopt(SO_SNDBUF) [%d]\n",Socket::DEFAULT_SOCKET_SENDBUF_SIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Socket::DEFAULT_SOCKET_RECVBUF_SIZE >= 0) {
|
||||||
|
int bufsize = 0;
|
||||||
|
socklen_t optlen = sizeof(bufsize);
|
||||||
|
|
||||||
|
int ret = getsockopt(sock, SOL_SOCKET, SO_RCVBUF, &bufsize, &optlen);
|
||||||
|
printf("Original setsockopt(SO_RCVBUF) = [%d] new will be [%d]\n",bufsize,Socket::DEFAULT_SOCKET_RECVBUF_SIZE);
|
||||||
|
|
||||||
|
ret = setsockopt( sock, SOL_SOCKET, SO_RCVBUF, (char *) &Socket::DEFAULT_SOCKET_RECVBUF_SIZE, sizeof( int ) );
|
||||||
|
if (ret == -1) {
|
||||||
|
printf("Couldn't setsockopt(SO_RCVBUF) [%d]\n",Socket::DEFAULT_SOCKET_RECVBUF_SIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float Socket::getThreadedPingMS(std::string host) {
|
float Socket::getThreadedPingMS(std::string host) {
|
||||||
|
Reference in New Issue
Block a user