wip trying to reproduce exam tester

This commit is contained in:
asus
2023-02-21 19:10:33 +01:00
parent 2d93332cf9
commit 37a45a9a0a
13 changed files with 280 additions and 404 deletions

View File

@@ -49,14 +49,14 @@ int main(int ac, char **av) {
if (ac != 2)
error("Wrong number of arguments\n");
if ( (port = atoi(av[1])) == -1)
error("Fatal error1\n");
error("Fatal error\n");
addr_len = sizeof(addr);
bzero(&addr, addr_len);
// socket create and verification
server_fd = socket(AF_INET, SOCK_STREAM, 0);
if (server_fd == -1)
error("Fatal error2\n");
error("Fatal error\n");
// assign IP, PORT
addr.sin_family = AF_INET;
@@ -65,9 +65,9 @@ int main(int ac, char **av) {
// Binding newly created socket to given IP and verification
if ((bind(server_fd, (const struct sockaddr *)&addr, addr_len)) == -1)
error("Fatal error3\n");
error("Fatal error\n");
if (listen(server_fd, 10) == -1)
error("Fatal error4\n");
error("Fatal error\n");
FD_ZERO(&fdset);
FD_SET(server_fd, &fdset);
@@ -102,11 +102,8 @@ int main(int ac, char **av) {
broadcast(msg, &wdset, max_fd, client_fd);
FD_CLR(client_fd, &fdset);
close(client_fd);
//if (client_fd == max_fd) {
// for(; max_fd > 2; --max_fd) {
// if (FD_ISSET(max_fd, &fdset))
// break;
// }
//while(FD_ISSET(tmp_max, &fdset) == 0) {
// --tmp_max;
//}
}
else if (ret > 0) {