version 1.3, 1998/04/28 22:13:23 |
version 1.4, 1998/08/18 04:02:11 |
|
|
{ |
{ |
struct hostent *hp; |
struct hostent *hp; |
struct servent *sp; |
struct servent *sp; |
|
extern int h_errno; |
|
|
msg.pid = htonl(getpid()); |
msg.pid = htonl(getpid()); |
/* look up the address of the local host */ |
/* look up the address of the local host */ |
hp = gethostbyname(my_machine_name); |
hp = gethostbyname(my_machine_name); |
if (hp == NULL) { |
if (hp == NULL) |
fprintf(stderr, "talk: %s: ", my_machine_name); |
errx(1, "%s: %s", my_machine_name, hstrerror(h_errno)); |
herror((char *)NULL); |
|
exit(-1); |
|
} |
|
bcopy(hp->h_addr, (char *)&my_machine_addr, hp->h_length); |
bcopy(hp->h_addr, (char *)&my_machine_addr, hp->h_length); |
/* |
/* |
* If the callee is on-machine, just copy the |
* If the callee is on-machine, just copy the |
|
|
*/ |
*/ |
if (strcmp(his_machine_name, my_machine_name)) { |
if (strcmp(his_machine_name, my_machine_name)) { |
hp = gethostbyname(his_machine_name); |
hp = gethostbyname(his_machine_name); |
if (hp == NULL) { |
if (hp == NULL) |
fprintf(stderr, "talk: %s: ", his_machine_name); |
errx(1, "%s: %s", his_machine_name, hstrerror(h_errno)); |
herror((char *)NULL); |
|
exit(-1); |
|
} |
|
bcopy(hp->h_addr, (char *) &his_machine_addr, hp->h_length); |
bcopy(hp->h_addr, (char *) &his_machine_addr, hp->h_length); |
} else |
} else |
his_machine_addr = my_machine_addr; |
his_machine_addr = my_machine_addr; |
/* find the server's port */ |
/* find the server's port */ |
sp = getservbyname("ntalk", "udp"); |
sp = getservbyname("ntalk", "udp"); |
if (sp == 0) { |
if (sp == NULL) |
fprintf(stderr, "talk: %s/%s: service is not registered.\n", |
errx(1, "ntalk/udp: service is not registered."); |
"ntalk", "udp"); |
|
exit(-1); |
|
} |
|
daemon_port = sp->s_port; |
daemon_port = sp->s_port; |
} |
} |