40 #ifndef SDL_BIG_ENDIAN
41 #error missing SDL_endian.h
56 if ((network ==
nullptr) || !network->
realConnect())
76 mMutexIn(SDL_CreateMutex()),
77 mMutexOut(SDL_CreateMutex()),
78 mSleep(
config.getIntValue(
"networksleep")),
105 logger->
log1(
"Tried to connect an already connected socket!");
112 setError(
_(
"Empty address given to Network::connect()!"));
116 logger->
log(
"Network::Connecting to %s:%i",
132 setError(
"Unable to create network worker thread");
174 setError(
"Error in TcpNet::send(): " +
217 _(
"Unable to resolve host \"")).append(
237 logger->
log_r(
"Network::Started session with %s:%i",
250 setError(
"Error in TcpNet::allocSocketSet(): " +
257 setError(
"Error in TcpNet::addSocket(): " +
298 setError(
_(
"Connection to server terminated. ") +
329 std::stringstream errorStream;
330 errorStream <<
"Error in TcpNet::recv(), " << numReady
352 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
353 return SDL_Swap16(*
reinterpret_cast<uint16_t*
>(
357 return (*
reinterpret_cast<uint16_t*
>(
SDL_Thread * mWorkerThread
friend int networkThread(void *data)
bool connect(const ServerInfo &server)
uint16_t readWord(const int pos) const
void setError(const std::string &error)
void log(const char *const log_text,...)
void log_r(const char *const log_text,...)
void log1(const char *const log_text)
bool error(InputEvent &event) __attribute__((noreturn))
const unsigned int BUFFER_SIZE
const unsigned int BUFFER_LIMIT
int networkThread(void *data)
SDL_Thread * createThread(int(*fn)(void *), const char *const name, void *const data)
void WaitThread(SDL_Thread *const thread)
int delSocket(const TcpNet::SocketSet set, const TcpNet::Socket sock)
::SDLNet_SocketSet SocketSet
int send(const TcpNet::Socket sock, const void *const data, const int len)
int resolveHost(IPaddress *const address, const char *const host, const Uint16 port)
void freeSocketSet(const TcpNet::SocketSet set)
TcpNet::Socket open(IPaddress *const ip)
int addSocket(const TcpNet::SocketSet set, const TcpNet::Socket sock)
SocketSet allocSocketSet(const int maxsockets)
int checkSockets(const TcpNet::SocketSet set, const Uint32 timeout)
void closeSocket(const TcpNet::Socket socket)
int recv(const TcpNet::Socket sock, void *const data, const int maxlen)
#define BLOCK_START(name)
const char * ipToString(const uint32_t address)