[enet-cvs] CVS: enet/test client.c,1.1,1.2 server.c,1.1,1.2
ENet CVS
enet-discuss@lists.puremagic.com
Fri, 7 Jun 2002 20:36:23 -0600
Update of /home/enet/cvsroot/enet/test
In directory sferik:/tmp/cvs-serv1180/test
Modified Files:
client.c server.c
Log Message:
Throttle changes, channels, bug fixes, etc.
Index: client.c
===================================================================
RCS file: /home/enet/cvsroot/enet/test/client.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- client.c 2002/02/10 21:27:03 1.1
+++ client.c 2002/06/08 02:36:20 1.2
@@ -1,49 +1,57 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <enet/enet.h>
-
-int
-main (void)
-{
- static char message [1024 * 1024];
- ENetAddress address;
- ENetEvent event;
- ENetHost * host;
- int i;
-
- for (i = 0; i < 8192; ++ i)
- sprintf (& message [i * 5], "%0.4d,", i);
-
- message [i * 5] = '\0';
-
- enet_address_set_host (& address, "127.0.0.1");
- address.port = 3000;
-
- host = enet_host_create (NULL, 1);
- if (host == NULL)
- return EXIT_FAILURE;
-
- enet_host_connect (host, & address);
-
- while (enet_host_service (host, & event, 10000) > 0)
- {
- switch (event.type)
- {
- case ENET_EVENT_TYPE_CONNECT:
- puts ("connect");
-
- enet_host_broadcast (host,
- enet_packet_create (message,
- strlen (message) + 1,
- 0));
-
- break;
- }
- }
-
- enet_host_destroy (host);
-
- return EXIT_SUCCESS;
-}
-
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <enet/enet.h>
+
+int
+main (int argc, char ** argv)
+{
+ static char message [1024 * 1024];
+ ENetAddress address;
+ ENetEvent event;
+ ENetHost * host;
+ int i, j;
+
+ if (argc < 2)
+ return EXIT_FAILURE;
+
+ j = atoi (argv [1]);
+
+ for (i = 0; i < j; ++ i)
+ sprintf (& message [i * 5], "%0.4d,", i);
+
+ message [i * 5] = '\0';
+
+ enet_address_set_host (& address, "127.0.0.1");
+ address.port = 3000;
+
+ host = enet_host_create (NULL, 1, 28 * 1024, 9 * 1024);
+ if (host == NULL)
+ return EXIT_FAILURE;
+
+ enet_host_connect (host, & address, 2);
+
+ while (enet_host_service (host, & event, 10000) >= 0)
+ {
+ switch (event.type)
+ {
+ case ENET_EVENT_TYPE_CONNECT:
+ puts ("connect");
+
+ break;
+ }
+
+ enet_host_broadcast (host,
+ 0,
+ enet_packet_create (message,
+ strlen (message) + 1,
+ 0));
+ }
+
+ puts ("Ugh");
+
+ enet_host_destroy (host);
+
+ return EXIT_SUCCESS;
+}
+
Index: server.c
===================================================================
RCS file: /home/enet/cvsroot/enet/test/server.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- server.c 2002/02/10 21:27:03 1.1
+++ server.c 2002/06/08 02:36:20 1.2
@@ -1,41 +1,39 @@
-#include <stdlib.h>
-#include <stdio.h>
-#include <enet/enet.h>
-
-int
-main (void)
-{
- ENetAddress address;
- ENetEvent event;
- ENetHost * host;
-
- enet_address_set_host (& address, "127.0.0.1");
- address.port = 3000;
-
- host = enet_host_create (& address, 1);
- if (host == NULL)
- return EXIT_FAILURE;
-
- while (enet_host_service (host, & event, 60000) > 0)
- {
- switch (event.type)
- {
- case ENET_EVENT_TYPE_RECEIVE:
- puts (event.packet -> data);
-
- enet_packet_destroy (event.packet);
-
- break;
-
- default:
- continue;
- }
-
- break;
- }
-
- enet_host_destroy (host);
-
- return EXIT_SUCCESS;
-}
-
+#include <stdlib.h>
+#include <stdio.h>
+#include <enet/enet.h>
+
+int
+main (void)
+{
+ ENetAddress address;
+ ENetEvent event;
+ ENetHost * host;
+
+ enet_address_set_host (& address, "127.0.0.1");
+ address.port = 3000;
+
+ host = enet_host_create (& address, 16, 56 * 1024, 14 * 1024);
+ if (host == NULL)
+ return EXIT_FAILURE;
+
+ while (enet_host_service (host, & event, 60000) >= 0)
+ {
+ switch (event.type)
+ {
+ case ENET_EVENT_TYPE_RECEIVE:
+ puts ("Receive!");
+ puts (event.packet -> data);
+
+ enet_packet_destroy (event.packet);
+
+ break;
+ }
+ }
+
+ puts ("Ugh");
+
+ enet_host_destroy (host);
+
+ return EXIT_SUCCESS;
+}
+