summaryrefslogtreecommitdiffhomepage
path: root/examples/network/network_udp_server.c
diff options
context:
space:
mode:
authorRay <[email protected]>2021-04-22 18:55:24 +0200
committerRay <[email protected]>2021-04-22 18:55:24 +0200
commitdcf52c132fb0ca28f37dae9d957155e2541df812 (patch)
treeb6c263e59daba00fc33badd0a45fa6756d5df14c /examples/network/network_udp_server.c
parentf92ee46d86b5a0cfb05c10b0c31fb966a4784b44 (diff)
downloadraylib-dcf52c132fb0ca28f37dae9d957155e2541df812.tar.gz
raylib-dcf52c132fb0ca28f37dae9d957155e2541df812.zip
Remove trail spaces
Diffstat (limited to 'examples/network/network_udp_server.c')
-rw-r--r--examples/network/network_udp_server.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/examples/network/network_udp_server.c b/examples/network/network_udp_server.c
index f32189c2..29fffbe7 100644
--- a/examples/network/network_udp_server.c
+++ b/examples/network/network_udp_server.c
@@ -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
//--------------------------------------------------------------------------------------