-static int getport(char * p)
-{
- unsigned int port = atoi(p);
-
- if ((unsigned)(port - 1 ) > 65534)
- {
- error_msg_and_die("%s: bad port number", p);
- }
- return port;
-}
-
-static struct in_addr getserver(char * host)
-{
- struct in_addr addr;
-
- struct hostent * he;
- if ((he = gethostbyname(host)) == NULL)
- {
- error_msg_and_die("%s: Unknown host", host);
- }
- memcpy(&addr, he->h_addr, sizeof addr);
-
- TRACE(1, ("addr: %s\n", inet_ntoa(addr)));
-
- return addr;
-}
-
-static int create_socket()
-{
- return socket(AF_INET, SOCK_STREAM, 0);
-}
-
-static void setup_sockaddr_in(struct sockaddr_in * addr, int port)
-{
- memset(addr, 0, sizeof(struct sockaddr_in));
- addr->sin_family = AF_INET;
- addr->sin_port = htons(port);
-}
-
-#if 0
-static int local_bind(int port)
-{
- struct sockaddr_in s_addr;
- int s = create_socket();
-
- setup_sockaddr_in(&s_addr, port);
-
- setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof one);
-
- if (bind(s, &s_addr, sizeof s_addr) < 0)
- {
- char * e = sys_errlist[errno];
- syserrorexit("bind");
- exit(1);
- }
- listen(s, 1);
-
- return s;
-}
-#endif
-
-static int remote_connect(struct in_addr addr, int port)
-{
- struct sockaddr_in s_addr;
- int s = create_socket();
-
- setup_sockaddr_in(&s_addr, port);
- s_addr.sin_addr = addr;
-
- setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof one);
-
- if (connect(s, (struct sockaddr *)&s_addr, sizeof s_addr) < 0)
- {
- perror_msg_and_die("Unable to connect to remote host");
- }
- return s;
-}
-