mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
close socket after using
This commit is contained in:
parent
8e98e47823
commit
d9be2da7b4
3 changed files with 4 additions and 0 deletions
|
@ -170,6 +170,7 @@ typedef struct ap_s {
|
||||||
time_t time;
|
time_t time;
|
||||||
uint32_t station_count;
|
uint32_t station_count;
|
||||||
uint8_t ssid[SSID_MAX_LEN];
|
uint8_t ssid[SSID_MAX_LEN];
|
||||||
|
uint32_t collision_domain;
|
||||||
} ap;
|
} ap;
|
||||||
|
|
||||||
// ---------------- Defines ----------------
|
// ---------------- Defines ----------------
|
||||||
|
|
|
@ -188,12 +188,14 @@ int add_tcp_conncection(char* ipv4, int port){
|
||||||
print_tcp_array();
|
print_tcp_array();
|
||||||
|
|
||||||
if(tcp_array_contains_address(serv_addr)) {
|
if(tcp_array_contains_address(serv_addr)) {
|
||||||
|
close(sockfd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (connect(sockfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0)
|
if (connect(sockfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0)
|
||||||
{
|
{
|
||||||
|
close(sockfd);
|
||||||
fprintf(stderr,"ERROR connecting\n");
|
fprintf(stderr,"ERROR connecting\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1346,6 +1346,7 @@ void send_tcp(char* msg)
|
||||||
for (int i = 0; i <= tcp_entry_last; i++) {
|
for (int i = 0; i <= tcp_entry_last; i++) {
|
||||||
if(send(network_array[i].sockfd, msg, strlen(msg), 0) < 0)
|
if(send(network_array[i].sockfd, msg, strlen(msg), 0) < 0)
|
||||||
{
|
{
|
||||||
|
close(network_array->sockfd);
|
||||||
printf("Removing bad TCP connection!\n");
|
printf("Removing bad TCP connection!\n");
|
||||||
for (int j = i; j < client_entry_last; j++) {
|
for (int j = i; j < client_entry_last; j++) {
|
||||||
network_array[j] = network_array[j + 1];
|
network_array[j] = network_array[j + 1];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue