#include <SDL/SDL.h>
#include <SDL/SDL_net.h>
#include <stdlib.h>
#include<vector>
SDL_Surface *screen;
TCPsocket client;
void init_sdl(void)
{
if (SDL_Init(SDL_INIT_VIDEO) < 0)
exit(-1);
atexit(SDL_Quit);
}
void init_net(void)
{
IPaddress addr;
if (SDLNet_Init() < 0)
{
printf("ERR Net: %s\n", SDLNet_GetError());
exit(-1);
}
/*ERROR PROPABLY I use ruter to cpnect lg phone and tablet lenowo change ip to local host*/
if (SDLNet_ResolveHost(&addr, "192.168.1.2", 1234) < 0)
{
printf("ERR ResolveHost: %s\n", SDLNet_GetError());
SDLNet_Quit();
exit(-1);
}
client = SDLNet_TCP_Open(&addr);
if (client == NULL)
{
printf("ERR TCP_Open: %s\n", SDLNet_GetError());
SDLNet_Quit();
exit(-1);
}
}
int main(void)
{
SDL_Rect rect;
std::vector<SDL_Rect> v1(1);
int maxread;
init_sdl();
init_net();
printf("Client-Socket ist offen\n");
// rect = new(SDL_Rect);
maxread = SDLNet_TCP_Recv(client, &v1[1], v1.size());;
printf("Read = %d\n", maxread);
/* zurückschicken */ printf("send back\n");
rect.x = 81;
rect.y = 92;
rect.w = 100;
rect.h = 200;
SDLNet_TCP_Send(client, &v1[1], v1.size());
return 0;
}
No comments:
Post a Comment