Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions server_ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ int main(void)
printf(ID "FTP Server started up @ local:%d. Waiting for client(s)...\n\n", PORTSERVER);
//END: initialization


while(1)
{
if((x = sfd_client = accept(sfd_server, (struct sockaddr*) &sin_client, &size_sockaddr)) < 0)
Expand All @@ -38,6 +37,7 @@ int main(void)

struct client_info* ci = client_info_alloc(sfd_client, connection_id++);
serve_client(ci);
free(ci);
}

close(sfd_server);
Expand All @@ -62,6 +62,7 @@ void* serve_client(void* info)
if((x = recv(sfd_client, data, size_packet, 0)) == 0)
{
fprintf(stderr, "client closed/terminated. closing connection.\n");
free(data);
break;
}

Expand Down Expand Up @@ -130,11 +131,12 @@ void* serve_client(void* info)
//show error, send TERM and break
fprintf(stderr, "packet incomprihensible. closing connection.\n");
send_TERM(shp, data, sfd_client);
free(data);
break;
}
}

free(data);
close(sfd_client);
fflush(stdout);
}