Socket
Librería para comunicar via TCP/IP
 Todo Clases Archivos Funciones Variables Páginas
Client

Ejemplo de aplicación cliente

#include "Socket.h"
#include <iostream>
#include <sstream>
#include <signal.h>
#include <cstdlib>
#include <sys/time.h>
using namespace std;
void exitClient(int signal)
{
cout << "Server connection terminated unexpectedly" << endl << "Exiting" << endl;
exit(-1);
}
int main()
{
signal(SIGPIPE, exitClient);
signal(SIGINT, exitClient);
Socket s;
string send, recv, host;
int port;
s.Create();
cout << "Created socket" << endl;
cout << "Hostname: ";
cin >> host;
cout << "Port: ";
cin >> port;
cin.ignore();
s.Connect(host,port);
cout << "Connected" << endl;
while(true)
{
cout << "> ";
getline(cin,send);
s >> recv;
cout << "Received: " << recv << endl;
}
}