32f401083ac387c96400c8926ff987062339e022
* Copyright (c) 1992 The Regents of the University of California
* Copyright (c) 1990, 1992 Jan-Simon Pendry
* This code is derived from software donated to Berkeley by
* %sccs.include.redist.c%
* @(#)pt_tcp.c 5.2 (Berkeley) %G%
* $Id: pt_tcp.c,v 1.1 1992/05/25 21:43:09 jsp Exp jsp $
* Key will be tcp/host/port[/"priv"]
* Create a TCP socket connected to the
* requested host and port.
* Some trailing suffix values have special meanings.
* An unrecognised suffix is an error.
int portal_tcp(pcr
, key
, v
, kso
, fdp
)
char host
[MAXHOSTNAMELEN
];
char port
[MAXHOSTNAMELEN
];
char *p
= key
+ (v
[1] ? strlen(v
[1]) : 0);
if (q
== 0 || q
- p
>= sizeof(host
))
if (q
== 0 || q
- p
>= sizeof(port
))
hp
= gethostbyname(host
);
ipp
= (struct in_addr
**) hp
->h_addr_list
;
ina
.s_addr
= inet_addr(host
);
if (ina
.s_addr
== INADDR_NONE
)
sp
= getservbyname(port
, "tcp");
bzero(&sain
, sizeof(sain
));
sain
.sin_len
= sizeof(sain
);
sain
.sin_family
= AF_INET
;
so
= socket(AF_INET
, SOCK_STREAM
, 0);
syslog(LOG_ERR
, "socket: %m");
if (connect(so
, (struct sockaddr
*) &sain
, sizeof(sain
)) == 0) {