Blame view

JChatClient/src/client.dox 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
/** @file
\author Imanol Barba Sabariego
\date 13/06/2013
\page client_code Client
\brief Ejemplo de aplicaciĆ³n cliente

\code{.cpp}
#include "Socket.h"
#include <iostream>
#include "SocketException.h"
#include <sstream>
#include <signal.h>
13
#include <cstdlib>
14
15
16
17
18
19
20
21
22
23
24
25
26
#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);
27
	signal(SIGINT, exitClient);
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
	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;
	}
}
\endcode
*/