diff options
Diffstat (limited to 'examples/network/network_udp_client.c')
| -rw-r--r-- | examples/network/network_udp_client.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/examples/network/network_udp_client.c b/examples/network/network_udp_client.c index 680ed00e..d351372b 100644 --- a/examples/network/network_udp_client.c +++ b/examples/network/network_udp_client.c @@ -24,22 +24,22 @@ int main(void) InitWindow(screenWidth, screenHeight, "raylib [network] example - udp client");
InitNetworkDevice(); // Init network communications
-
+
const char *pingmsg = "Ping!";
const char *pongmsg = "Pong!";
-
+
bool ping = true;
bool pong = false;
float elapsed = 0.0f;
float delay = 1.0f;
SocketConfig clientConfig = {
- .host = "127.0.0.1",
- .port = "4950",
- .type = SOCKET_UDP,
+ .host = "127.0.0.1",
+ .port = "4950",
+ .type = SOCKET_UDP,
.nonblocking = true
};
-
+
SocketResult *clientResult = NULL;
SocketSet *socketSet = NULL;
char receiveBuffer[512] = { 0 };
@@ -76,7 +76,7 @@ int main(void) if (IsSocketReady(clientResult->socket)) bytesRecv = SocketReceive(clientResult->socket, receiveBuffer, (int)strlen(pingmsg) + 1);
// If we received data, was 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; }
@@ -86,17 +86,17 @@ int main(void) elapsed += GetFrameTime();
if (elapsed > delay)
{
- if (ping)
+ if (ping)
{
ping = false;
SocketSend(clientResult->socket, pingmsg, (int)strlen(pingmsg) + 1);
- }
+ }
else if (pong)
{
pong = false;
SocketSend(clientResult->socket, pongmsg, (int)strlen(pongmsg) + 1);
}
-
+
elapsed = 0.0f;
}
//----------------------------------------------------------------------------------
@@ -106,7 +106,7 @@ int main(void) BeginDrawing();
ClearBackground(RAYWHITE);
-
+
// TODO: Draw relevant connection info
EndDrawing();
@@ -116,7 +116,7 @@ int main(void) // De-Initialization
//--------------------------------------------------------------------------------------
CloseNetworkDevice(); // Close network communication
-
+
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
|
