fix numéro de port

This commit is contained in:
Yohan Simard 2021-02-24 18:10:58 +01:00
parent 472741b134
commit 13c05b02a3
2 changed files with 13 additions and 13 deletions

View file

@ -23,25 +23,25 @@ int main (int argc, char * argv[]) {
exit(2);
}
int sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock == -1) {
printf("ERREUR lors de la création du socket\n");
exit(1);
}
int sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock == -1) {
printf("ERREUR lors de la création du socket\n");
exit(1);
}
// On cree l'adresse du socket target
struct sockaddr_in addr_target;
addr_target.sin_family = AF_INET;
addr_target.sin_port = atoi(argv[2]);
struct hostent * hoststruct = gethostbyname(argv[1]);
if (hoststruct == NULL){
printf("ERREUR lors de la recherche de l'adresse IP du target\n");
exit(1);
addr_target.sin_port = htons(atoi(argv[2]));
struct hostent *hoststruct = gethostbyname(argv[1]);
if (hoststruct == NULL) {
printf("ERREUR lors de la recherche de l'adresse IP du target\n");
exit(1);
}
memcpy((char *)&(addr_target.sin_addr.s_addr), hoststruct->h_addr, hoststruct->h_length);
memcpy((char *) &(addr_target.sin_addr.s_addr), hoststruct->h_addr, hoststruct->h_length);
int retour_connexion;
//On fait de demande de connextion au socket target

View file

@ -164,7 +164,7 @@ int main(int argc, char *argv[]) {
int binder;
addr_local.sin_family = AF_INET;
addr_local.sin_port = atoi(argv[1]);
addr_local.sin_port = htons(atoi(argv[1]));
addr_local.sin_addr.s_addr = INADDR_ANY;
// On bind l'adresse du socket créee avec le socket local