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