Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //http://www.youtube.com/user/thecplusplusguy
- //a simple client for networking with SDL_Net
- #include <iostream>
- #include <SDL/SDL.h>
- #include <SDL/SDL_net.h>
- #include <cstring>
- int main(int argc,char** argv)
- {
- SDL_Init(SDL_INIT_EVERYTHING);
- SDLNet_Init();
- IPaddress ip;
- //write "127.0.0.1",1234 to connect to the server.cpp on your local machine
- SDLNet_ResolveHost(&ip,"www.linux.org",80);
- const char* http="GET / HTTP/1.1\nHost: www.linux.org\n\n";
- TCPsocket client=SDLNet_TCP_Open(&ip);
- SDLNet_TCP_Send(client,http,strlen(http)+1);
- char text[10000];
- while(SDLNet_TCP_Recv(client,text,10000))
- std::cout << text;
- SDLNet_TCP_Close(client);
- SDLNet_Quit();
- SDL_Quit();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement