static char sccsid
[] = "@(#)bsdtcp.c 4.4 (Berkeley) %G%";
* bsdtcpopn -- make a tcp connection
struct sockaddr_in hisctladdr
;
extern char *sys_errlist
[];
sp
= getservbyname(flds
[F_CLASS
], "tcp");
port
= htons(atoi(flds
[F_CLASS
]));
logent(_FAILED
, "UNKNOWN PORT NUMBER");
DEBUG(4, "bsdtcpopn host %s, ", flds
[F_PHONE
]);
DEBUG(4, "port %d\n", ntohs(port
));
logent("tcpopen", "TIMEOUT");
bzero((char *)&hisctladdr
, sizeof (hisctladdr
));
hp
= gethostbyname(flds
[F_PHONE
]);
logent("tcpopen","UNKNOWN HOST");
signal(SIGALRM
, alarmtr
);
hisctladdr
.sin_family
= hp
->h_addrtype
;
s
= socket(SOCK_STREAM
, 0, &hisctladdr
, 0);
s
= socket(hp
->h_addrtype
, SOCK_STREAM
, 0);
if (bind(s
, (char *)&hisctladdr
, sizeof (hisctladdr
), 0) < 0)
bcopy(hp
->h_addr
, (char *)&hisctladdr
.sin_addr
, hp
->h_length
);
hisctladdr
.sin_port
= port
;
if (connect(s
, (char *)&hisctladdr
) < 0)
if (connect(s
, (char *)&hisctladdr
, sizeof (hisctladdr
), 0) < 0)
DEBUG(5, "tcpopen failed: errno %d\n", errno
);
logent(sys_errlist
[errno
], _FAILED
);
* bsdtcpcls -- close tcp connection
DEBUG(4, "TCP CLOSE called\n", 0);
DEBUG(4, "closed fd %d\n", fd
);