Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tarea2-RC-Grupo25-Cliente
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ramiro Facundo Lorenzo Rodriguez Inthamoussu
Tarea2-RC-Grupo25-Cliente
Commits
01fabf08
Commit
01fabf08
authored
7 years ago
by
Leonardo
Browse files
Options
Downloads
Patches
Plain Diff
cliente con textos en ingles
parent
3627c6d9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/cliente.cpp
+17
-17
17 additions, 17 deletions
src/cliente.cpp
with
17 additions
and
17 deletions
src/cliente.cpp
+
17
−
17
View file @
01fabf08
...
@@ -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 servido
r.
\n
"
);
printf
(
"Error
. Cannot establish connection to seve
r.
\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 servido
r.
\n
"
);
printf
(
"Error
. Cannot establish connection to seve
r.
\n
"
);
return
;
return
;
}
}
printf
(
"Cone
x
ion establ
ecida
.
\n
"
);
printf
(
"Cone
ct
ion establ
ished
.
\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
(
"C
errando
socket
s a
%s:%d
\n
"
,
HOST
,
TCP_PORT
);
printf
(
"C
losing
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
(
"Dat
os
rec
ibidos
: %d
\n
"
,
received_data_size
);
printf
(
"Dat
a
rec
eived
: %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
(
"N
uevo
jpeg size: %
zu
\n
"
,
sizeof
(
jpg
));
printf
(
"N
ew
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
(
"N
uevo
jpeg size: %d
\n
"
,
size
);
printf
(
"N
ew
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 whe
n
creating socket"
);
if
(
sock
<
0
)
error
(
"error wh
il
e 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
Suscrip
c
ion
a
%s:%d ...
\n
"
,
HOSTNAME
,
UDP_PORT
);
::
fflush
(
stdout
);
printf
(
"
Sending
Su
b
scrip
t
ion
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
serv
ido
r.
\n
"
);
printf
(
"Error, no
Accept response from
serv
e
r.
\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
serv
ido
r.
\n
"
);
printf
(
"Error, no
response from
serv
e
r.
\n
"
);
break
;
break
;
}
else
{
}
else
{
printf
(
"Error
al recibir
dat
os
.
\n
"
);
printf
(
"Error
while receiving
dat
a
.
\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
(
"C
errando
sockets
a
%s:%d, keepAliveId %s
\n
"
,
HOSTNAME
,
UDP_PORT
,
keepAliveId
);
printf
(
"C
losing
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
(
"E
RROR: primer argumento debe ser
TCP o UDP.
\n
"
);
printf
(
"E
rror, first argument should read
TCP o
r
UDP.
\n
"
);
return
-
1
;
return
-
1
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment