Remove trail spaces

This commit is contained in:
Ray 2021-04-22 18:55:24 +02:00
parent f92ee46d86
commit dcf52c132f
61 changed files with 565 additions and 565 deletions

View file

@ -24,30 +24,30 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [network] example - udp server");
InitNetworkDevice(); // Init network communications
const char *pingmsg = "Ping!";
const char *pongmsg = "Pong!";
bool ping = false;
bool pong = false;
float elapsed = 0.0f;
float delay = 1.0f;
SocketConfig serverConfig = {
.host = "127.0.0.1",
.port = "4950",
.server = true,
.type = SOCKET_UDP,
.host = "127.0.0.1",
.port = "4950",
.server = true,
.type = SOCKET_UDP,
.nonblocking = true
};
SocketResult *serverResult = NULL;
SocketSet *socketSet = NULL;
char receiveBuffer[512] = { 0 };
// Create the server: getaddrinfo + socket + setsockopt + bind + listen
serverResult = LoadSocketResult();
if (!SocketCreate(&serverConfig, serverResult)) TraceLog(LOG_WARNING, "Failed to open server: status %d, errno %d", serverResult->status, serverResult->socket->status);
else if (!SocketBind(&serverConfig, serverResult)) TraceLog(LOG_WARNING, "Failed to bind server: status %d, errno %d", serverResult->status, serverResult->socket->status);
@ -65,7 +65,7 @@ int main(void)
//----------------------------------------------------------------------------------
// Once connected to the network, check the sockets for pending information
// and when information is ready, send either a Ping or a Pong.
// CheckSockets, if any of the sockets in the set are pending (received data, or requests)
// then mark the socket as being ready. You can check this with IsSocketReady(client_res->socket)
int active = CheckSockets(socketSet, 0);
@ -79,7 +79,7 @@ int main(void)
int bytesRecv = SocketReceive(serverResult->socket, receiveBuffer, (int)strlen(pingmsg) + 1);
// If we received data, is that data a "Ping!" or a "Pong!"?
if (bytesRecv > 0)
if (bytesRecv > 0)
{
if (strcmp(receiveBuffer, pingmsg) == 0) { pong = true; }
if (strcmp(receiveBuffer, pongmsg) == 0) { ping = true; }
@ -87,20 +87,20 @@ int main(void)
// After each delay has expired, send a response "Ping!" for a "Pong!" and vice-versa
elapsed += GetFrameTime();
if (elapsed > delay)
{
if (ping)
if (ping)
{
ping = false;
SocketSend(serverResult->socket, pingmsg, (int)strlen(pingmsg) + 1);
}
else if (pong)
}
else if (pong)
{
pong = false;
SocketSend(serverResult->socket, pongmsg, (int)strlen(pongmsg) + 1);
}
elapsed = 0.0f;
}
//----------------------------------------------------------------------------------
@ -120,7 +120,7 @@ int main(void)
// De-Initialization
//--------------------------------------------------------------------------------------
CloseNetworkDevice(); // Close network communication
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------