4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 * The Regents of the University of California
35 * University Acknowledgment- Portions of this document are derived from
36 * software developed by the University of California, Berkeley, and its
40 #pragma ident "%Z%%M% %I% %E% SMI"
43 * This file handles haggling with the various talk daemons to
44 * get a socket to talk to. sockt is opened and connected in
51 struct sockaddr_in daemon_addr
= { AF_INET
};
52 struct sockaddr_in ctl_addr
= { AF_INET
};
53 struct sockaddr_in my_addr
= { AF_INET
};
55 /* inet addresses of the two machines */
56 struct in_addr my_machine_addr
;
57 struct in_addr rem_machine_addr
;
59 u_short daemon_port
; /* port number of the talk daemon */
63 int invitation_waiting
= 0;
72 my_addr
.sin_addr
= my_machine_addr
;
75 sockt
= socket(AF_INET
, SOCK_STREAM
, 0);
78 p_error(gettext("Bad socket"));
81 if (bind(sockt
, (struct sockaddr
*)&my_addr
, sizeof (my_addr
)) != 0) {
82 p_error(gettext("Binding local socket"));
85 length
= (socklen_t
) sizeof (my_addr
);
87 if (getsockname(sockt
, (struct sockaddr
*)&my_addr
, &length
) == -1) {
88 p_error(gettext("Bad address for socket"));
92 /* open the ctl socket */
99 ctl_addr
.sin_port
= 0;
100 ctl_addr
.sin_addr
= my_machine_addr
;
102 ctl_sockt
= socket(AF_INET
, SOCK_DGRAM
, 0);
104 if (ctl_sockt
<= 0) {
105 p_error(gettext("Bad socket"));
108 if (bind(ctl_sockt
, (struct sockaddr
*)&ctl_addr
, sizeof (ctl_addr
))
110 p_error(gettext("Couldn't bind to control socket"));
113 length
= (socklen_t
) sizeof (ctl_addr
);
114 if (getsockname(ctl_sockt
, (struct sockaddr
*)&ctl_addr
, &length
)
116 p_error(gettext("Bad address for ctl socket"));
120 /* print_addr is a debug print routine */
124 struct sockaddr_in addr
;
128 printf("addr = %x, port = %o, family = %o zero = ",
129 addr
.sin_addr
, (int)addr
.sin_port
, addr
.sin_family
);
131 for (i
= 0; i
< 8; i
++) {
132 printf("%o ", (int)addr
.sin_zero
[i
]);