#include #include int main() { int s, opt; struct sockaddr_in addr; #if 1 printf("Fails!\n"); /* printf("Succeeds!\n"); */ #endif if ((s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) { perror("socket"); exit(1); } #if 0 opt = 1; if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt)) < 0) { perror("setsockopt"); exit(1); } #endif addr.sin_family = AF_INET; addr.sin_addr.s_addr = inet_addr("127.0.0.1"); addr.sin_port = htons(9998); if (bind(s, (struct sockaddr *)&addr, sizeof (addr))) { perror("bind"); exit(1); } if (listen(s, 5) == -1) { perror("listen"); exit(1); } printf("Success!\n"); sleep(500); return 0; }