diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-05-07 21:36:45 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-05-07 21:36:45 +0000 |
commit | 8ec687b21a279d9156a0e02c82f3feee265f8a1a (patch) | |
tree | 912b60688be89b97f764ff73a90fc448805bc48b /src/client.cpp | |
parent | aede3ee7379be250a538c31f03f2a922846760fb (diff) | |
download | manaserv-8ec687b21a279d9156a0e02c82f3feee265f8a1a.tar.gz manaserv-8ec687b21a279d9156a0e02c82f3feee265f8a1a.tar.bz2 manaserv-8ec687b21a279d9156a0e02c82f3feee265f8a1a.tar.xz manaserv-8ec687b21a279d9156a0e02c82f3feee265f8a1a.zip |
Committed client to be used for testing.
Diffstat (limited to 'src/client.cpp')
-rw-r--r-- | src/client.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
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; +} |