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
4e7a56f2
Commit
4e7a56f2
authored
Apr 13, 2020
by
pernelle
Browse files
création de la fonction envoiStructureCOL3_s()
parent
6810565e
Changes
2
Hide whitespace changes
Inline
Side-by-side
communCOL3-TP1.c
View file @
4e7a56f2
...
...
@@ -184,7 +184,8 @@ void envoiMessageCOL3(int sock, const char * msgresponse) {
/**
/**
DEPRECATED
cette fonction envoi une structure (mastructure) par la socket (sock)
p.pernelle / d.wayntal - 2018
...
...
@@ -198,6 +199,36 @@ void envoiStructureCOL3(int sock, void * mastructure,int taille) {
}
}
/**
* cette fonction envoi une structure (mastructure) par la socket (sock) de façon securisée
* retourne -1 en cas d'echec
* retourne 1 en cas de succes
*
* p.pernelle - 2020
*/
int
envoiStructureCOL3_s
(
int
sock
,
void
*
mastructure
,
int
taille
,
int
logFlag
)
{
struct
sockaddr_in
addresIPClient
;
int
longAdresseIPClient
=
sizeof
(
addresIPClient
);
int
ret
=-
1
;
if
(
getpeername
(
sock
,
&
addresIPClient
,
&
longAdresseIPClient
)
==
-
1
)
{
if
(
logFlag
)
printf
(
" --> socket[envoiStructureCOL3] : socket %d non connectée | envoi [NOK]
\n
"
,
sock
);
}
else
{
if
(
send
(
sock
,
(
char
*
)
mastructure
,
taille
,
0
)
<
0
)
{
if
(
logFlag
)
printf
(
" --> socket[envoiStructureCOL3] : envoi [NOK] | socket %d
\n
"
,
sock
);
}
else
{
if
(
logFlag
)
printf
(
" --> socket[envoiStructureCOL3] : envoi [OK] | socket %d vers IP = %s | taille = %d
\n
"
,
sock
,
inet_ntoa
(
addresIPClient
.
sin_addr
),
taille
);
ret
=
1
;
}
}
return
ret
;
}
/* ===========================================================
...
...
communCOL3-TP1.h
View file @
4e7a56f2
...
...
@@ -162,12 +162,21 @@ int connexionServeurCOL3(const char *adresse_serveur,int port, const char *token
*/
void
envoiMessageCOL3
(
int
sock
,
const
char
*
msgresponse
);
/**
DEPRECATED
cette fonction envoi une structure (mastructure) par la socket (sock)
p.pernelle / d.wayntal - 2018
*/
void
envoiStructureCOL3
(
int
sock
,
void
*
mastructure
,
int
taille
);
/**
* cette fonction envoi une structure (mastructure) par la socket (sock) de façon securisée
* retourne -1 en cas d'echec
* retourne 1 en cas de succes
*
* p.pernelle - 2020
*/
int
envoiStructureCOL3_s
(
int
sock
,
void
*
mastructure
,
int
taille
,
int
logFlag
);
/* ===========================================================
les fonctions de lecture de données depuis le serveur
...
...
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