ping-pong example now supports udp

added socket sets (query for non-blocking sockets)
removed rpack.h
removed old-packing helpers

Signed-off-by: Jak Barnes <contact@jakbarnes.co.uk>
This commit is contained in:
Jak Barnes 2019-02-24 21:54:02 +00:00
parent ee85f59643
commit 1f11913d8c
13 changed files with 2165 additions and 2339 deletions

View File

@ -1,53 +1,43 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [network] example - Chat client * raylib [core] example - Basic window
* *
* Welcome to raylib! * Welcome to raylib!
* *
* To test examples, just press F6 and execute raylib_compile_execute script * To test examples, just press F6 and execute raylib_compile_execute script
* Note that compiled executable is placed in the same folder as .c file * Note that compiled executable is placed in the same folder as .c file
* *
* You can find all basic examples on C:\raylib\raylib\examples folder or * You can find all basic examples on C:\raylib\raylib\examples folder or
* raylib official webpage: www.raylib.com * raylib official webpage: www.raylib.com
* *
* Enjoy using raylib. :) * Enjoy using raylib. :)
* *
* This example has been created using raylib 2.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*for details) *
* * Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5) *
* ********************************************************************************************/
********************************************************************************************/
#include "raylib.h"
#include "raylib.h"
int main()
int main() {
{ int screenWidth = 800;
// Setup int screenHeight = 450;
int screenWidth = 800; InitWindow(
int screenHeight = 450; screenWidth, screenHeight, "raylib [core] example - basic window");
InitWindow( SetTargetFPS(60);
screenWidth, screenHeight, "raylib [network] example - ping pong");
SetTargetFPS(60); // Main game loop
while (!WindowShouldClose())
// Networking {
InitNetwork(); BeginDrawing();
ClearBackground(RAYWHITE);
// Main game loop DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
while (!WindowShouldClose()) EndDrawing();
{ }
// Draw CloseWindow();
BeginDrawing();
return 0;
// Clear
ClearBackground(RAYWHITE);
// End draw
EndDrawing();
}
// Cleanup
CloseWindow();
return 0;
} }

View File

@ -1,56 +1,43 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [network] example - Chat server * raylib [core] example - Basic window
* *
* Welcome to raylib! * Welcome to raylib!
* *
* To test examples, just press F6 and execute raylib_compile_execute script * To test examples, just press F6 and execute raylib_compile_execute script
* Note that compiled executable is placed in the same folder as .c file * Note that compiled executable is placed in the same folder as .c file
* *
* You can find all basic examples on C:\raylib\raylib\examples folder or * You can find all basic examples on C:\raylib\raylib\examples folder or
* raylib official webpage: www.raylib.com * raylib official webpage: www.raylib.com
* *
* Enjoy using raylib. :) * Enjoy using raylib. :)
* *
* This example has been created using raylib 2.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*for details) *
* * Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5) *
* ********************************************************************************************/
********************************************************************************************/
#include "raylib.h"
#include "raylib.h"
int main()
#define MYPORT "4950" {
#define MAXBUFLEN 100 int screenWidth = 800;
int screenHeight = 450;
int main() InitWindow(
{ screenWidth, screenHeight, "raylib [core] example - basic window");
// Setup SetTargetFPS(60);
int screenWidth = 800;
int screenHeight = 450; // Main game loop
InitWindow( while (!WindowShouldClose())
screenWidth, screenHeight, "raylib [network] example - ping pong"); {
SetTargetFPS(60); BeginDrawing();
ClearBackground(RAYWHITE);
// Networking DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
InitNetwork(); EndDrawing();
}
// Main game loop CloseWindow();
while (!WindowShouldClose())
{ return 0;
// Draw
BeginDrawing();
// Clear
ClearBackground(RAYWHITE);
// End draw
EndDrawing();
}
// Cleanup
CloseWindow();
return 0;
} }

View File

@ -22,6 +22,9 @@
#include "raylib.h" #include "raylib.h"
#include <stdio.h>
#include <string.h>
int main() int main()
{ {
// Setup // Setup
@ -31,56 +34,46 @@ int main()
screenWidth, screenHeight, "raylib [network] example - ping pong"); screenWidth, screenHeight, "raylib [network] example - ping pong");
SetTargetFPS(60); SetTargetFPS(60);
SetTraceLogLevel(LOG_INFO); SetTraceLogLevel(LOG_DEBUG);
// Networking // Networking
InitNetwork(); InitNetwork();
// Create the server // Create the server
SocketConfig server_cfg = { SocketConfig server_cfg = {.host = "127.0.0.1", .port = "8080", .server = true, .datagram = true, .nonblocking = true};
.host = "127.0.0.1", SocketResult* server_res = AllocSocketResult();
.port = "8080", if (!SocketOpen(&server_cfg, server_res))
.server = true,
.nonblocking = true
};
SocketResult server_res;
memset(&server_res, 0, sizeof(SocketResult));
{ {
bool ok = SocketOpen(&server_cfg, &server_res); TraceLog(LOG_WARNING, "Failed to open server: status %d, errno %d\n",
if (!ok) server_res->status, server_res->socket->status);
{
return false;
}
} }
// Create the client // Create the client
SocketConfig client_cfg = { SocketConfig client_cfg = {.host = "127.0.0.1", .port = "8080", .datagram = true, .nonblocking = true};
.host = "127.0.0.1", SocketResult* client_res = AllocSocketResult();
.port = "8080"
};
SocketResult client_res;
memset(&client_res, 0, sizeof(SocketResult));
{ {
bool ok = SocketOpen(&client_cfg, &client_res); if (!SocketOpen(&client_cfg, client_res))
if (!ok)
{ {
printf("failed to open: status %d, errno %d\n", client_res.status, TraceLog(LOG_WARNING, "Failed to open client: status %d, errno %d\n",
client_res.socket.error); client_res->status, client_res->socket->status);
return false;
} }
} }
SocketResult connection; char recvBuffer[512];
memset(&connection, 0, sizeof(SocketResult)); memset(recvBuffer, '\0', sizeof(recvBuffer));
float elapsed = 0.0f, delay = 1.0f; // ms Socket* connection = NULL;
bool ping = false, pong = false; SocketConfig connection_cfg = { .nonblocking = true,.datagram = true };
char recvBuffer[512]; float elapsed = 0.0f;
bool connected = false; float delay = 1.0f;
memset(&recvBuffer, 0, 8); bool ping = false;
char pingmsg[6] = "Ping!"; bool pong = false;
char pongmsg[6] = "Pong!"; bool connected = false;
const char* pingmsg = "Ping!";
const char* pongmsg = "Pong!";
const int msglen = strlen(pingmsg) + 1;
SocketSet* socket_set = CreateSocketSet(3);
AddSocket(socket_set, server_res->socket);
AddSocket(socket_set, client_res->socket);
// Main game loop // Main game loop
while (!WindowShouldClose()) while (!WindowShouldClose())
@ -91,20 +84,51 @@ int main()
// Clear // Clear
ClearBackground(RAYWHITE); ClearBackground(RAYWHITE);
int active = CheckSockets(socket_set, 0);
if (active != 0)
{
TraceLog(LOG_DEBUG,
"There are currently %d socket(s) with data to be processed.", active);
}
// A valid connection will != -1 // A valid connection will != -1
if (!connected) if (!connected)
{ {
if (SocketAccept(server_res.socket.handle, &connection)) if (server_cfg.datagram)
{ {
ping = true; ping = true;
connected = true; connected = true;
} }
else
{
if ((connection = SocketAccept(server_res->socket, &connection_cfg)) != NULL)
{
AddSocket(socket_set, connection);
ping = true;
connected = true;
}
}
} }
// Connected // Connected
if (connected) if (connected)
{ {
int bytesRecv = SocketReceive(&connection.socket, recvBuffer, sizeof(pingmsg)); int bytesRecv = 0;
if (server_cfg.datagram)
{
if (IsSocketReady(server_res->socket))
{
bytesRecv = SocketReceive(server_res->socket, recvBuffer, msglen, 0);
}
}
else
{
if (IsSocketReady(connection))
{
bytesRecv = SocketReceive(connection, recvBuffer, msglen, 0);
}
}
if (bytesRecv > 0) if (bytesRecv > 0)
{ {
if (strcmp(recvBuffer, pingmsg) == 0) if (strcmp(recvBuffer, pingmsg) == 0)
@ -125,12 +149,12 @@ int main()
if (ping) if (ping)
{ {
ping = false; ping = false;
SocketSend(&client_res.socket, pingmsg, sizeof(pingmsg)); SocketSend(client_res->socket, pingmsg, msglen);
} }
else if (pong) else if (pong)
{ {
pong = false; pong = false;
SocketSend(&client_res.socket, pongmsg, sizeof(pongmsg)); SocketSend(client_res->socket, pongmsg, msglen);
} }
elapsed = 0.0f; elapsed = 0.0f;
} }

View File

@ -35,9 +35,8 @@ int main()
// Networking // Networking
InitNetwork(); InitNetwork();
AddressInformation addr; ResolveHost("www.google.com", "80");
ResolveHost("www.google.com", "80", &addr);
ResolveIP("8.8.8.8", NULL, NAME_INFO_DEFAULT); ResolveIP("8.8.8.8", NULL, NAME_INFO_DEFAULT);
ResolveIP("2001:4860:4860::8888", "80", NAME_INFO_NUMERICSERV); ResolveIP("2001:4860:4860::8888", "80", NAME_INFO_NUMERICSERV);

View File

@ -1,74 +1,43 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [network] example - Resolve host * raylib [core] example - Basic window
* *
* Welcome to raylib! * Welcome to raylib!
* *
* To test examples, just press F6 and execute raylib_compile_execute script * To test examples, just press F6 and execute raylib_compile_execute script
* Note that compiled executable is placed in the same folder as .c file * Note that compiled executable is placed in the same folder as .c file
* *
* You can find all basic examples on C:\raylib\raylib\examples folder or * You can find all basic examples on C:\raylib\raylib\examples folder or
* raylib official webpage: www.raylib.com * raylib official webpage: www.raylib.com
* *
* Enjoy using raylib. :) * Enjoy using raylib. :)
* *
* This example has been created using raylib 2.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*for details) *
* * Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5) *
* ********************************************************************************************/
********************************************************************************************/
#include "raylib.h"
#include "raylib.h" int main()
#include <string.h> {
int screenWidth = 800;
int main() int screenHeight = 450;
{ InitWindow(
// Setup screenWidth, screenHeight, "raylib [core] example - basic window");
int screenWidth = 800; SetTargetFPS(60);
int screenHeight = 450;
InitWindow( // Main game loop
screenWidth, screenHeight, "raylib [network] example - ping pong"); while (!WindowShouldClose())
SetTargetFPS(60); {
BeginDrawing();
SetTraceLogLevel(LOG_DEBUG); ClearBackground(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
// Networking EndDrawing();
InitNetwork(); }
CloseWindow();
unsigned char buf[1024];
unsigned char magic; return 0;
int monkeycount;
long altitude;
double absurdityfactor;
char* s = "Great unmitigated Zot! You've found the Runestaff!";
char s2[96];
unsigned int packetsize, ps2;
packetsize = PackData(buf, "CHhlsd", 'B', 0, 37, -5, s, -3490.5);
packi16(buf + 1, packetsize); // store packet size in packet for kicks
printf("packet is %u bytes\n", packetsize);
UnpackData(buf, "CHhl96sd", &magic, &ps2, &monkeycount, &altitude, s2, &absurdityfactor);
printf("'%c' %hhu %u %ld \"%s\" %f\n", magic, ps2, monkeycount, altitude, s2, absurdityfactor);
// Main game loop
while (!WindowShouldClose())
{
// Draw
BeginDrawing();
// Clear
ClearBackground(RAYWHITE);
// End draw
EndDrawing();
}
// Cleanup
CloseWindow();
return 0;
} }

View File

@ -1,93 +1,43 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [network] example - Resolve host * raylib [core] example - Basic window
* *
* Welcome to raylib! * Welcome to raylib!
* *
* To test examples, just press F6 and execute raylib_compile_execute script * To test examples, just press F6 and execute raylib_compile_execute script
* Note that compiled executable is placed in the same folder as .c file * Note that compiled executable is placed in the same folder as .c file
* *
* You can find all basic examples on C:\raylib\raylib\examples folder or * You can find all basic examples on C:\raylib\raylib\examples folder or
* raylib official webpage: www.raylib.com * raylib official webpage: www.raylib.com
* *
* Enjoy using raylib. :) * Enjoy using raylib. :)
* *
* This example has been created using raylib 2.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*for details) *
* * Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5) *
* ********************************************************************************************/
********************************************************************************************/
#include "raylib.h"
#include "raylib.h"
int main()
#include <string.h> {
int screenWidth = 800;
#define PORT "3490" // the port client will be connecting to int screenHeight = 450;
#define MAXDATASIZE 100 // max number of bytes we can get at once InitWindow(
screenWidth, screenHeight, "raylib [core] example - basic window");
int main() SetTargetFPS(60);
{
// Setup // Main game loop
int screenWidth = 800; while (!WindowShouldClose())
int screenHeight = 450; {
InitWindow( BeginDrawing();
screenWidth, screenHeight, "raylib [network] example - ping pong"); ClearBackground(RAYWHITE);
SetTargetFPS(60); DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
EndDrawing();
SetTraceLogLevel(LOG_DEBUG); }
CloseWindow();
// Networking
InitNetwork(); return 0;
int numbytes;
char buf[MAXDATASIZE];
// Create the client
SocketConfig client_cfg = {
.host = "127.0.0.1",
.port = "8080"
};
SocketResult client_res;
memset(&client_res, 0, sizeof(SocketResult));
{
bool ok = SocketOpen(&client_cfg, &client_res);
if (!ok)
{
printf("Failed to open: status %d, errno %d\n", client_res.status,
client_res.socket.error);
return false;
}
}
// Main game loop
while (!WindowShouldClose())
{
// Draw
BeginDrawing();
// Clear
ClearBackground(RAYWHITE);
// Receive bytes from the server
numbytes = SocketReceive(client_res.socket.handle, buf, MAXDATASIZE - 1);
if (numbytes == -1)
{
printf("Client: error recv '%s'\n", buf);
break;
}
buf[numbytes] = '\0';
printf("Client: received '%s'\n", buf);
break;
// End draw
EndDrawing();
}
// Cleanup
SocketClose(client_res.socket.handle);
CloseNetwork();
CloseWindow();
return 0;
} }

View File

@ -1,100 +1,43 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [network] example - Resolve host * raylib [core] example - Basic window
* *
* Welcome to raylib! * Welcome to raylib!
* *
* To test examples, just press F6 and execute raylib_compile_execute script * To test examples, just press F6 and execute raylib_compile_execute script
* Note that compiled executable is placed in the same folder as .c file * Note that compiled executable is placed in the same folder as .c file
* *
* You can find all basic examples on C:\raylib\raylib\examples folder or * You can find all basic examples on C:\raylib\raylib\examples folder or
* raylib official webpage: www.raylib.com * raylib official webpage: www.raylib.com
* *
* Enjoy using raylib. :) * Enjoy using raylib. :)
* *
* This example has been created using raylib 2.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*for details) *
* * Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5) *
* ********************************************************************************************/
********************************************************************************************/
#include "raylib.h"
#include "raylib.h" int main()
#include <string.h> {
int screenWidth = 800;
int main() int screenHeight = 450;
{ InitWindow(
// Setup screenWidth, screenHeight, "raylib [core] example - basic window");
int screenWidth = 800; SetTargetFPS(60);
int screenHeight = 450;
InitWindow( // Main game loop
screenWidth, screenHeight, "raylib [network] example - ping pong"); while (!WindowShouldClose())
SetTargetFPS(60); {
BeginDrawing();
SetTraceLogLevel(LOG_DEBUG); ClearBackground(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
// Networking EndDrawing();
InitNetwork(); }
CloseWindow();
// Create the server return 0;
SocketConfig server_cfg = {
.host = "127.0.0.1",
.port = "8080",
.server = true,
.nonblocking = true
};
SocketResult server_res;
memset(&server_res, 0, sizeof(SocketResult));
{
bool ok = SocketOpen(&server_cfg, &server_res);
if (!ok)
{
return false;
}
}
SocketResult connection;
memset(&connection, 0, sizeof(SocketResult));
char recvBuffer[512];
memset(&recvBuffer, 0, 8);
bool connected = false;
// Main game loop
while (!WindowShouldClose())
{
// Draw
BeginDrawing();
// Clear
ClearBackground(RAYWHITE);
// Wait for a valid connection
if (!connected)
{
if (SocketAccept(server_res.socket.handle, &connection))
{
connected = true;
}
}
if (connected)
{
SocketSend(&connection, "Hello, world!", 13);
}
// End draw
EndDrawing();
}
// Cleanup
CloseWindow();
return 0;
} }

View File

@ -1,74 +1,43 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [network] example - Resolve host * raylib [core] example - Basic window
* *
* Welcome to raylib! * Welcome to raylib!
* *
* To test examples, just press F6 and execute raylib_compile_execute script * To test examples, just press F6 and execute raylib_compile_execute script
* Note that compiled executable is placed in the same folder as .c file * Note that compiled executable is placed in the same folder as .c file
* *
* You can find all basic examples on C:\raylib\raylib\examples folder or * You can find all basic examples on C:\raylib\raylib\examples folder or
* raylib official webpage: www.raylib.com * raylib official webpage: www.raylib.com
* *
* Enjoy using raylib. :) * Enjoy using raylib. :)
* *
* This example has been created using raylib 2.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*for details) *
* * Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5) *
* ********************************************************************************************/
********************************************************************************************/
#include "raylib.h"
#include "raylib.h" int main()
#include <string.h> {
int screenWidth = 800;
int main() int screenHeight = 450;
{ InitWindow(
// Setup screenWidth, screenHeight, "raylib [core] example - basic window");
int screenWidth = 800; SetTargetFPS(60);
int screenHeight = 450;
InitWindow( // Main game loop
screenWidth, screenHeight, "raylib [network] example - ping pong"); while (!WindowShouldClose())
SetTargetFPS(60); {
BeginDrawing();
SetTraceLogLevel(LOG_DEBUG); ClearBackground(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
// Networking EndDrawing();
InitNetwork(); }
CloseWindow();
unsigned char buf[1024];
unsigned char magic; return 0;
int monkeycount;
long altitude;
double absurdityfactor;
char* s = "Great unmitigated Zot! You've found the Runestaff!";
char s2[96];
unsigned int packetsize, ps2;
packetsize = PackData(buf, "CHhlsd", 'B', 0, 37, -5, s, -3490.5);
packi16(buf + 1, packetsize); // store packet size in packet for kicks
printf("packet is %u bytes\n", packetsize);
UnpackData(buf, "CHhl96sd", &magic, &ps2, &monkeycount, &altitude, s2, &absurdityfactor);
printf("'%c' %hhu %u %ld \"%s\" %f\n", magic, ps2, monkeycount, altitude, s2, absurdityfactor);
// Main game loop
while (!WindowShouldClose())
{
// Draw
BeginDrawing();
// Clear
ClearBackground(RAYWHITE);
// End draw
EndDrawing();
}
// Cleanup
CloseWindow();
return 0;
} }

View File

@ -1,74 +1,43 @@
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [network] example - Resolve host * raylib [core] example - Basic window
* *
* Welcome to raylib! * Welcome to raylib!
* *
* To test examples, just press F6 and execute raylib_compile_execute script * To test examples, just press F6 and execute raylib_compile_execute script
* Note that compiled executable is placed in the same folder as .c file * Note that compiled executable is placed in the same folder as .c file
* *
* You can find all basic examples on C:\raylib\raylib\examples folder or * You can find all basic examples on C:\raylib\raylib\examples folder or
* raylib official webpage: www.raylib.com * raylib official webpage: www.raylib.com
* *
* Enjoy using raylib. :) * Enjoy using raylib. :)
* *
* This example has been created using raylib 2.0 (www.raylib.com) * This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*for details) *
* * Copyright (c) 2013-2016 Ramon Santamaria (@raysan5)
* Copyright (c) 2013-2016 Ramon Santamaria (@raysan5) *
* ********************************************************************************************/
********************************************************************************************/
#include "raylib.h"
#include "raylib.h" int main()
#include <string.h> {
int screenWidth = 800;
int main() int screenHeight = 450;
{ InitWindow(
// Setup screenWidth, screenHeight, "raylib [core] example - basic window");
int screenWidth = 800; SetTargetFPS(60);
int screenHeight = 450;
InitWindow( // Main game loop
screenWidth, screenHeight, "raylib [network] example - ping pong"); while (!WindowShouldClose())
SetTargetFPS(60); {
BeginDrawing();
SetTraceLogLevel(LOG_DEBUG); ClearBackground(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
// Networking EndDrawing();
InitNetwork(); }
CloseWindow();
unsigned char buf[1024];
unsigned char magic; return 0;
int monkeycount;
long altitude;
double absurdityfactor;
char* s = "Great unmitigated Zot! You've found the Runestaff!";
char s2[96];
unsigned int packetsize, ps2;
packetsize = PackData(buf, "CHhlsd", 'B', 0, 37, -5, s, -3490.5);
packi16(buf + 1, packetsize); // store packet size in packet for kicks
printf("packet is %u bytes\n", packetsize);
UnpackData(buf, "CHhl96sd", &magic, &ps2, &monkeycount, &altitude, s2, &absurdityfactor);
printf("'%c' %hhu %u %ld \"%s\" %f\n", magic, ps2, monkeycount, altitude, s2, absurdityfactor);
// Main game loop
while (!WindowShouldClose())
{
// Draw
BeginDrawing();
// Clear
ClearBackground(RAYWHITE);
// End draw
EndDrawing();
}
// Cleanup
CloseWindow();
return 0;
} }

View File

@ -185,7 +185,6 @@
<ClInclude Include="..\..\..\src\raylib.h" /> <ClInclude Include="..\..\..\src\raylib.h" />
<ClInclude Include="..\..\..\src\raymath.h" /> <ClInclude Include="..\..\..\src\raymath.h" />
<ClInclude Include="..\..\..\src\rlgl.h" /> <ClInclude Include="..\..\..\src\rlgl.h" />
<ClInclude Include="..\..\..\src\rpack.h" />
<ClInclude Include="..\..\..\src\sysnet.h" /> <ClInclude Include="..\..\..\src\sysnet.h" />
<ClInclude Include="..\..\..\src\utils.h" /> <ClInclude Include="..\..\..\src\utils.h" />
</ItemGroup> </ItemGroup>

File diff suppressed because it is too large Load Diff

1274
src/rnet.c

File diff suppressed because it is too large Load Diff

View File

@ -185,6 +185,19 @@ typedef long int int64;
#ifndef RESULT_FAILURE #ifndef RESULT_FAILURE
# define RESULT_FAILURE 1 # define RESULT_FAILURE 1
#endif // RESULT_FAILURE #endif // RESULT_FAILURE
#ifndef INADDR_ANY
# define INADDR_ANY 0x00000000
#endif // INADDR_ANY
#ifndef INADDR_NONE
# define INADDR_NONE 0xFFFFFFFF
#endif // INADDR_NONE
#ifndef INADDR_LOOPBACK
# define INADDR_LOOPBACK 0x7f000001
#endif // INADDR_LOOPBACK
#ifndef INADDR_BROADCAST
# define INADDR_BROADCAST 0xFFFFFFFF
#endif // INADDR_BROADCAST
#ifndef htonll #ifndef htonll
# ifdef _BIG_ENDIAN # ifdef _BIG_ENDIAN
@ -206,9 +219,9 @@ typedef long int int64;
#ifdef _WIN32 #ifdef _WIN32
# pragma comment(lib, "ws2_32.lib") # pragma comment(lib, "ws2_32.lib")
# define __USE_W32_SOCKETS # define __USE_W32_SOCKETS
# include <winsock2.h>
# include <Ws2tcpip.h> # include <Ws2tcpip.h>
# include <io.h> # include <io.h>
# include <winsock2.h>
# define IPTOS_LOWDELAY 0x10 # define IPTOS_LOWDELAY 0x10
#else /* UNIX */ #else /* UNIX */
# include <sys/types.h> # include <sys/types.h>