- if (host)
- {
- if ((s.sin_addr.s_addr = inet_addr(host)) == -1)
- {
- hp = gethostbyname(host);
- if (!hp)
- fatal("Host not found");
- s.sin_addr = *(struct in_addr *)(hp->h_addr_list[0]);
- }
- }
- else
- s.sin_addr.s_addr = inet_addr("127.0.0.1");
-
- s.sin_port = htons(port);
- s.sin_family = AF_INET;
- sfd = socket(PF_INET, SOCK_STREAM, 0);
- if (sfd < 0)
- fatal("Out of file descriptors");
- if ((tcpproto = getprotobyname("tcp")) != NULL)
- setsockopt(sfd, tcpproto->p_proto, TCP_NODELAY, (char *)&on, sizeof(int));
-
- if (connect(sfd, (struct sockaddr *)&s, sizeof(s)) < 0)