my problem is that the server is stopped, put the code here.
I do not want the server to stop
Video of the problemhttp://www.youtube.com/watch?v=CA4zsZoiV3I&feature=youtu.beSERVER#include <iostream>
#include <SFML/Network.hpp>
using namespace std;
// Puerto 25569
int main(int argc,char *argv[]){
sf::SocketTCP Conexion;
sf::SocketTCP Client;
sf::IPAddress ClientAddress;
sf::Packet Paquete;
int t;
Conexion.Listen(25569);
Conexion.SetBlocking(false);
for(int i=0;;i++){
for(int j=0;j<100000000;j++);//this is for do a little pause
if(Client.Receive(Paquete)!=sf::Socket::Done){
Conexion.Accept(Client,&ClientAddress);
}
else {
Paquete >> t;
cout << "Client: " << t<< endl;
Conexion.Close();
}
cout << i<< "-juan es gilipollas"<<endl;
}
return 0;
}
CLIENT#include <iostream>
#include <SFML/Network.hpp>
#include <cstdio>
using namespace std;
// Puerto 25569
struct Suma{
int n1;
int n2;
};
int main(int argc,char *argv[]){
sf::SocketTCP Conexion;
sf::Packet Paquete;
while(Conexion.Connect(25569,sf::IPAddress("localhost")) !=sf::Socket::Done)cout << "Buscando servidor..."<<endl;
cout << "Servidor encontrado." <<endl;
//char Datos[128];
Suma s;
while(1){
cout << "Escribe el primer numero: ";
cin >> s.n2;
Paquete << s.n2;
Conexion.Connect(25569,sf::IPAddress("localhost"));
if(Conexion.Send(Paquete) != sf::Socket::Done)cout << "no se pudo mandar el mensaje";
Paquete.Clear();
}
return 0;
}