summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmakeclient.sh2
-rw-r--r--src/client.cpp41
2 files changed, 43 insertions, 0 deletions
diff --git a/makeclient.sh b/makeclient.sh
new file mode 100755
index 00000000..7b5b9e21
--- /dev/null
+++ b/makeclient.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+g++ -I/usr/include/SDL -D_REENTRANT -o client src/client.cpp -L/usr/lib -lSDL_net -lSDL -lpthread
diff --git a/src/client.cpp b/src/client.cpp
new file mode 100644
index 00000000..99b1e3dd
--- /dev/null
+++ b/src/client.cpp
@@ -0,0 +1,41 @@
+#include <SDL.h>
+#include <SDL_net.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[])
+{
+ // Initialize SDL
+ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1) {
+ printf("SDL_Init: %s\n", SDL_GetError());
+ exit(1);
+ }
+
+ // Set SDL to quit on exit
+ atexit(SDL_Quit);
+
+ // Initialize SDL_net
+ if (SDLNet_Init() == -1) {
+ printf("SDLNet_Init: %s\n", SDLNet_GetError());
+ exit(2);
+ }
+
+ // Try to connect to server
+ IPaddress ip;
+ TCPsocket tcpsock;
+
+ if (SDLNet_ResolveHost(&ip, "localhost", 9601) == -1) {
+ printf("SDLNet_ResolveHost: %s\n", SDLNet_GetError());
+ exit(1);
+ }
+
+ tcpsock = SDLNet_TCP_Open(&ip);
+ if (!tcpsock) {
+ printf("SDLNet_TCP_Open: %s\n", SDLNet_GetError());
+ exit(2);
+ }
+
+ printf("Succesfully connected!\n");
+ SDLNet_TCP_Close(tcpsock);
+
+ return 0;
+}