#include #include #include #include #include #include #include #include #include #include int main(){ struct sockaddr_in sad; sad.sin_port = htons(1337); sad.sin_addr.s_addr = INADDR_ANY; sad.sin_family = AF_INET; int skt = socket(AF_INET, SOCK_STREAM, 0); bind(skt, (struct sockaddr *)(&sad), sizeof(struct sockaddr_in)); listen(skt, 5); char type[5]; uint64_t a, b; for(;;){ int client_fd = accept(skt, 0, 0); while(read(client_fd, type, 4) == 4){ read(client_fd, &a, 8); read(client_fd, &b, 8); if(b == 0){ write(client_fd, "LAZY", 4); a = 1; } else { if(strncmp(type, "DIVI", 4) == 0){ a = a / b; } else { a = a % b; } write(client_fd, "RESL", 4); } write(client_fd, &a, 8); } close(client_fd); } return 0; }