Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Info604
col3-bibtp1
Commits
52d50292
Commit
52d50292
authored
Apr 04, 2020
by
pernelle
Browse files
re-correction du bug sur nbrecu
parent
53895bb8
Changes
1
Hide whitespace changes
Inline
Side-by-side
communCOL3-TP1.c
View file @
52d50292
...
...
@@ -174,23 +174,16 @@ int connexionServeurCOL3(const char *adresse_serveur,int port, const char *token
*/
void
envoiMessageCOL3
(
int
sock
,
const
char
*
msgresponse
)
{
if
(
send
(
sock
,
msgresponse
,
strlen
(
msgresponse
),
0
)
<
0
)
{
if
(
!
NCURSE
)
printf
(
"%s %s %s"
,
" --> socket[
lire
MessageCOL3] : envoi msg = {"
,
msgresponse
,
"} [NOK]
\n
"
);
if
(
!
NCURSE
)
printf
(
"%s %s %s"
,
" --> socket[
envoi
MessageCOL3] : envoi msg = {"
,
msgresponse
,
"} [NOK]
\n
"
);
}
else
{
if
(
!
NCURSE
)
printf
(
"%s %s %s"
,
" --> socket[
lire
MessageCOL3] : envoi msg = {"
,
msgresponse
,
"} [OK]
\n
"
);
if
(
!
NCURSE
)
printf
(
"%s %s %s"
,
" --> socket[
envoi
MessageCOL3] : envoi msg = {"
,
msgresponse
,
"} [OK]
\n
"
);
}
}
/**
cette fonction envoi une structure (mastructure) par la socket (sock)
...
...
@@ -198,10 +191,10 @@ void envoiMessageCOL3(int sock, const char * msgresponse) {
*/
void
envoiStructureCOL3
(
int
sock
,
void
*
mastructure
,
int
taille
)
{
if
(
send
(
sock
,
(
char
*
)
mastructure
,
taille
,
0
)
<
0
)
{
perror
(
"envoi message
[NOK]"
);
if
(
!
NCURSE
)
printf
(
"%s"
,
" --> socket[envoiStructureCOL3] : envoi
[NOK]
\n
"
);
}
else
{
if
(
!
NCURSE
)
printf
(
"%s %d %s"
,
"
-->
envoi
st
ucture
de
taille ="
,
taille
,
"
\n
"
);
if
(
!
NCURSE
)
printf
(
"%s %d %s"
,
"
--> socket[
envoi
Str
ucture
COL3] : envoi
taille =
"
,
taille
,
"
[OK]
\n
"
);
}
}
...
...
@@ -228,14 +221,18 @@ void lireMessageCOL3(int sock, char * msgrecu) {
if
(
!
NCURSE
)
printf
(
"%s %d %s"
,
" --> socket[lireMessageCOL3] : en attente reception message (MAX="
,
TAILLE_MAX_MSG
,
") ...
\n
"
);
/* attente en reception d'un message emis par le serveur */
if
((
nbrecu
=
recv
(
sock
,
temp
,
sizeof
(
temp
),
0
))
<
0
)
{
if
(
!
NCURSE
)
printf
(
"%s"
,
" --> socket[lireMessageCOL3] : reception message [NOK]
\n
"
);
}
temp
[
nbrecu
<
0
?
0
:
nbrecu
]
=
'\0'
;
strcpy
(
msgrecu
,
temp
);
if
(
!
NCURSE
)
printf
(
"%s %d %s %s %s "
,
" --> socket[lireMessageCOL3] : reception message [OK] : nbrecu = "
,
nbrecu
,
" msg = {"
,
msgrecu
,
"}
\n
"
);
}
if
((
nbrecu
=
recv
(
sock
,
temp
,
sizeof
(
temp
),
0
))
<=
0
)
{
if
(
!
NCURSE
)
printf
(
"%s %d %s"
,
" --> socket[lireMessageCOL3] : reception message [NOK] : nbrecu = "
,
nbrecu
,
"
\n
"
);
strcpy
(
msgrecu
,
""
);
}
else
{
temp
[
nbrecu
]
=
'\0'
;
strcpy
(
msgrecu
,
temp
);
if
(
!
NCURSE
)
printf
(
"%s %d %s %s %s "
,
" --> socket[lireMessageCOL3] : reception message [OK] : nbrecu = "
,
nbrecu
,
" msg = {"
,
msgrecu
,
"}
\n
"
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment