close socket after using

This commit is contained in:
PolynomialDivision 2018-01-06 13:48:12 +01:00
parent 8e98e47823
commit d9be2da7b4
3 changed files with 4 additions and 0 deletions

View file

@ -170,6 +170,7 @@ typedef struct ap_s {
time_t time;
uint32_t station_count;
uint8_t ssid[SSID_MAX_LEN];
uint32_t collision_domain;
} ap;
// ---------------- Defines ----------------

View file

@ -188,12 +188,14 @@ int add_tcp_conncection(char* ipv4, int port){
print_tcp_array();
if(tcp_array_contains_address(serv_addr)) {
close(sockfd);
return 0;
}
if (connect(sockfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0)
{
close(sockfd);
fprintf(stderr,"ERROR connecting\n");
return 0;
}

View file

@ -1346,6 +1346,7 @@ void send_tcp(char* msg)
for (int i = 0; i <= tcp_entry_last; i++) {
if(send(network_array[i].sockfd, msg, strlen(msg), 0) < 0)
{
close(network_array->sockfd);
printf("Removing bad TCP connection!\n");
for (int j = i; j < client_entry_last; j++) {
network_array[j] = network_array[j + 1];