Skip to content
Snippets Groups Projects
Commit 01fabf08 authored by Leonardo's avatar Leonardo
Browse files

cliente con textos en ingles

parent 3627c6d9
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@ using namespace cv;
/** CONSTANTES Y CONFIGURACION **/
const char delimiter[] = "Grupo25";
const int keepAliveIntervalSeconds = 5;
const int keepAliveIntervalSeconds = 30;
const bool debug = false;
// DEFINICION DE FUNCIONES
......@@ -85,11 +85,11 @@ void TCP(const char* HOST){
hints.ai_socktype = SOCK_STREAM;
getaddrinfo(HOST, STR(TCP_PORT), &hints, &res);
printf("Intentando conexion con %s:%d ...\n",HOST,TCP_PORT);
printf("Trying to connect to %s:%d ...\n",HOST,TCP_PORT);
//primitiva CONNECT
if (connect(client_socket, res->ai_addr, res->ai_addrlen)<0){
printf("Error, imposible establecer conexion con el servidor.\n");
printf("Error. Cannot establish connection to sever.\n");
return;
}
......@@ -101,10 +101,10 @@ void TCP(const char* HOST){
int msg_size = strlen(msg);
int sent_msg_size = send(client_socket, msg, msg_size, 0);
if (sent_msg_size == -1) {
printf("Error, imposible establecer conexion con el servidor.\n");
printf("Error. Cannot establish connection to sever.\n");
return;
}
printf("Conexion establecida.\n");
printf("Conection established.\n");
char buf[MAXLEN]; // se almacenan los datos TCP recibidos en cada recv
char recibido[MAXLEN]; // mantiene el historico de datos recibidos, quitando los frames ya dibujados
......@@ -118,7 +118,7 @@ void TCP(const char* HOST){
fin = printFrame( received_data_size, recibido, fin, buf);
}
printf("Cerrando sockets a %s:%d\n", HOST, TCP_PORT);
printf("Closing socket to %s:%d\n", HOST, TCP_PORT);
close(client_socket);
freeaddrinfo(res);
......@@ -127,7 +127,7 @@ void TCP(const char* HOST){
int printFrame(int received_data_size, char* recibido, int fin, char* buf){
if (debug) {
printf("Datos recibidos: %d\n", received_data_size);
printf("Data received: %d\n", received_data_size);
}
// en el arrray 'recibido' se mantiene los datos que ya exisitian mas los nuevos.
for(int j = 0; j < received_data_size; j++)
......@@ -142,7 +142,7 @@ int printFrame(int received_data_size, char* recibido, int fin, char* buf){
jpg[h] = recibido[inicio+h];
if (debug) {
printf("Nuevo jpeg size: %zu\n", sizeof(jpg));
printf("New jpeg, size: %li\n", sizeof(jpg));
}
namedWindow("cliente", CV_WINDOW_AUTOSIZE);
Mat rawData = Mat(1, found, CV_8UC1, jpg);
......@@ -163,7 +163,7 @@ int printFrame(int received_data_size, char* recibido, int fin, char* buf){
void printFrameUDP(char* jpg, int size){
if (debug) {
printf("Nuevo jpeg size: %d\n", size);
printf("New jpeg, size: %d\n", size);
}
namedWindow("cliente", CV_WINDOW_AUTOSIZE);
Mat rawData = Mat(1, size, CV_8UC1, jpg);
......@@ -180,14 +180,14 @@ void UDP(char* HOSTNAME){
// CREATE SOCKET
int sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0) error("error when creating socket");
if (sock < 0) error("error while creating socket");
char buffer[256];
bzero(buffer,256);
sprintf(buffer, "SUBSCRIPTION");
// ENVIO PEDIDO DE SUSCRIPCION
printf("Enviando Suscripcion a %s:%d ...\n", HOSTNAME, UDP_PORT); ::fflush(stdout);
printf("Sending Subscription to %s:%d ...\n", HOSTNAME, UDP_PORT); ::fflush(stdout);
if (sendDatagramUDPtoHostname(sock, HOSTNAME, buffer, UDP_PORT) < 0)
error("Error on send first datagram");
......@@ -201,10 +201,10 @@ void UDP(char* HOSTNAME){
struct sockaddr_in from;
if (recvfrom(sock,buffer,256,0,(struct sockaddr *)&from, &length) < 0){
if ((errno == EAGAIN) || (errno == EWOULDBLOCK)){
printf("Error, no hay respuesta del servidor.\n");
printf("Error, no Accept response from server.\n");
return;
}else{
printf("Error al recibir ACEEPT del servidor\n");
printf("Error while receiving Accept data\n");
return;
}
}
......@@ -238,10 +238,10 @@ void UDP(char* HOSTNAME){
received_data_size = recvfrom( sock , buf , MAXLEN , 0 , (struct sockaddr *)&from , &length );
if (received_data_size < 1){
if ((received_data_size < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK))){
printf("Error, no hay respuesta del servidor.\n");
printf("Error, no response from server.\n");
break;
}else{
printf("Error al recibir datos.\n");
printf("Error while receiving data.\n");
break;
}
}else {
......@@ -257,7 +257,7 @@ void UDP(char* HOSTNAME){
// error("recv from UDP frames");
// printf("%s\n", frameBuffer);
//}
printf("Cerrando sockets a %s:%d, keepAliveId %s\n", HOSTNAME, UDP_PORT, keepAliveId);
printf("Closing sockets to %s:%d, keepAliveId %s\n", HOSTNAME, UDP_PORT, keepAliveId);
close(sock);
}
......@@ -328,7 +328,7 @@ int main(int argc, char *argv[]) {
}else if (strcmp(upCase(argv[1]),"UDP") == 0){
UDP(argv[2]);
}else{
printf("ERROR: primer argumento debe ser TCP o UDP.\n");
printf("Error, first argument should read TCP or UDP.\n");
return -1;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment