+ return 1;
+}
+
+static int socket_server(int port)
+{
+ struct sockaddr_in sin;
+ int sock;
+ int n;
+
+ impersonate_hmlanif = 1;
+
+ sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (sock == -1) {
+ perror("Can't open socket");
+ return EXIT_FAILURE;
+ }
+
+ n = 1;
+ if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &n, sizeof(n)) == -1) {
+ perror("Can't set socket options");
+ return EXIT_FAILURE;
+ }
+
+ memset(&sin, 0, sizeof(sin));
+ sin.sin_family = AF_INET;
+ sin.sin_port = htons(port);
+ sin.sin_addr.s_addr = htonl(INADDR_ANY);
+
+ if (bind(sock, (struct sockaddr*)&sin, sizeof(sin)) == -1) {
+ perror("Can't bind socket");
+ return EXIT_FAILURE;
+ }
+
+ if (listen(sock, 1) == -1) {
+ perror("Can't listen on socket");
+ return EXIT_FAILURE;
+ }
+
+ while(1) {
+ struct sockaddr_in csin;
+ socklen_t csinlen;
+ int client;
+
+ memset(&csin, 0, sizeof(csin));
+ csinlen = sizeof(csin);
+ client = accept(sock, (struct sockaddr*)&csin, &csinlen);
+ if (client == -1) {
+ perror("Couldn't accept client");
+ continue;
+ }
+
+ printf("Client accepted!\n");
+
+ comm(client, client, sock);
+
+ shutdown(client, SHUT_RDWR);
+ close(client);
+
+ printf("Connection closed!\n");
+
+ }
+
+ return EXIT_SUCCESS;
+}
+
+static int interactive_server(void)
+{
+ if (!comm(STDIN_FILENO, STDOUT_FILENO, -1))
+ return EXIT_FAILURE;