esque estoy intentando hacer street fighter "online por asi decirlo" poco a poco conforme voy aprendiendo.
y mi problema llega aqui.
e conseguido que desde el cliente se mueva el pj en servidor.
pero ahora supongomago para hacer 1 partida de 1vs1:
PC 1 envia informacion al PC 2 . "PC 1 cliente, PC 2 servidor"
PC 2 actualiza los datos enviados del PC 1.
PC 2 envia informacion al PC1 . "PC 2 cliente , PC 1 servidor"
PC 1 actualiza los datos enviados del PC2.
...
para hacer esto deberian de ser servidor-cliente.
eso se puede hacer?
Nuevo code.
explico.
si se pone el exit(1) en el punto indicado se cierra hasta a i bien. peor el problema es que hay 1 orden antes que no la hace, que es guardar X datos en el archivo externo
Código
#include <iostream> #include <fstream> #include <SDL/SDL.h> #include <SDL/SDL_image.h> #include <SDL/SDL_net.h> using namespace std; SDL_Surface *screen; SDL_Event evento; Uint8 *tecla; //////////////////////////////////////////////////////////// ofstream LOG("log.txt",ios::out); ofstream ERROR("error.txt",ios::out); //////////////////////////////////////////////////////////// IPaddress ipservidor,*ipremitente,ipcliente; TCPsocket sservidor,sremitente,scliente; //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// char DATOS[10]; int main(int argc,char *argv[]){ SDL_Init(SDL_INIT_VIDEO); SDLNet_Init(); screen=SDL_SetVideoMode(540,480,32,SDL_SWSURFACE); SDL_WM_SetCaption("Servidor-Cliente, By Xafi ...",0); //servidor SDLNet_ResolveHost(&ipservidor,0,2000); sservidor=SDLNet_TCP_Open(&ipservidor); //cliente SDLNet_ResolveHost(&ipcliente,"127.0.0.1",2000); scliente=SDLNet_TCP_Open(&ipcliente); // while(1){ SDL_Delay(30); //LOG << "\nCONEXIONES: \tServidor: " << SDLNet_Read32(&ipservidor.host) << "\tCliente: " << SDLNet_Read32(&ipremitente->host); SDLNet_TCP_Send(scliente,"cliente conectado",512); if(sremitente=SDLNet_TCP_Accept(sservidor)){ ERROR << "CONECTADO"; ipremitente=SDLNet_TCP_GetPeerAddress(sremitente); while(1){ LOG << "\nCONEXION: " << SDLNet_Read32(&ipremitente->host); //pongan la siguiente linea //exit(1) SDLNet_TCP_Recv(sremitente,DATOS,512); tecla=SDL_GetKeyState(0); SDL_PollEvent(&evento); if(tecla[SDLK_ESCAPE])exit(1); } } else ERROR << "\n" << SDLNet_GetError(); } }