// test2.c - the part of TCP states test (FIN_WAIT1 + ESTABLISHED) #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { int fd = socket(AF_INET, SOCK_STREAM, 0); struct sockaddr_in addr; addr.sin_family = AF_INET; addr.sin_addr.s_addr = inet_addr("127.0.0.1"); addr.sin_port = htons(6666); if (connect(fd, (struct sockaddr*)&addr, sizeof(addr)) == -1) return 1; while (1) { sleep(1); } return 0; }