diff options
| author | Ray <[email protected]> | 2021-04-22 18:55:24 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2021-04-22 18:55:24 +0200 |
| commit | dcf52c132fb0ca28f37dae9d957155e2541df812 (patch) | |
| tree | b6c263e59daba00fc33badd0a45fa6756d5df14c /examples/network/network_tcp_client.c | |
| parent | f92ee46d86b5a0cfb05c10b0c31fb966a4784b44 (diff) | |
| download | raylib-dcf52c132fb0ca28f37dae9d957155e2541df812.tar.gz raylib-dcf52c132fb0ca28f37dae9d957155e2541df812.zip | |
Remove trail spaces
Diffstat (limited to 'examples/network/network_tcp_client.c')
| -rw-r--r-- | examples/network/network_tcp_client.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/examples/network/network_tcp_client.c b/examples/network/network_tcp_client.c index b2daab48..1779a3a4 100644 --- a/examples/network/network_tcp_client.c +++ b/examples/network/network_tcp_client.c @@ -24,10 +24,10 @@ int main(void) InitWindow(screenWidth, screenHeight, "raylib [network] example - tcp client");
InitNetworkDevice(); // Init network communications
-
+
const char *pingmsg = "Ping!";
const char *pongmsg = "Pong!";
-
+
bool ping = false;
bool pong = false;
float elapsed = 0.0f;
@@ -35,12 +35,12 @@ int main(void) bool connected = false;
SocketConfig clientConfig = {
- .host = "127.0.0.1",
- .port = "4950",
- .type = SOCKET_TCP,
+ .host = "127.0.0.1",
+ .port = "4950",
+ .type = SOCKET_TCP,
.nonblocking = true
};
-
+
SocketSet *socketSet = NULL;
SocketResult *clientResult = NULL;
char receiveBuffer[512] = { 0 };
@@ -48,9 +48,9 @@ int main(void) // Create the client: getaddrinfo + socket + setsockopt + connect (TCP only)
clientResult = LoadSocketResult();
if (!SocketCreate(&clientConfig, clientResult)) TraceLog(LOG_WARNING, "Failed to open client: status %d, errno %d", clientResult->status, clientResult->socket->status);
- else
+ else
{
- if (!(clientConfig.type == SOCKET_UDP))
+ if (!(clientConfig.type == SOCKET_UDP))
{
if (!SocketConnect(&clientConfig, clientResult)) TraceLog(LOG_WARNING, "Failed to connect to server: status %d, errno %d", clientResult->status, clientResult->socket->status);
}
@@ -83,7 +83,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; }
@@ -91,19 +91,19 @@ int main(void) // After each delay has expired, send a response "Ping!" for a "Pong!" and vice versa
elapsed += GetFrameTime();
- if (elapsed > delay)
+ if (elapsed > delay)
{
- if (ping)
+ if (ping)
{
ping = false;
SocketSend(clientResult->socket, pingmsg, (int)strlen(pingmsg) + 1);
}
- else if (pong)
+ else if (pong)
{
pong = false;
SocketSend(clientResult->socket, pongmsg, (int)strlen(pingmsg) + 1);
}
-
+
elapsed = 0.0f;
}
}
@@ -124,7 +124,7 @@ int main(void) BeginDrawing();
ClearBackground(RAYWHITE);
-
+
// TODO: Draw relevant connection info
EndDrawing();
@@ -134,7 +134,7 @@ int main(void) // De-Initialization
//--------------------------------------------------------------------------------------
CloseNetworkDevice(); // Close network communication
-
+
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
|
