/* * See if the local daemon has a invitation for us */ check_local() { CTL_RESPONSE response; /* the rest of msg was set up in get_names */ msg.ctl_addr = ctl_addr; /* must be initiating a talk */ if (!look_for_invite(&response)) return (0); /* * There was an invitation waiting for us, * so connect with the other (hopefully waiting) party */ current_state = "Waiting to connect with caller"; again: swapresponse(&response); if (connect(sockt, &response.addr, sizeof(response.addr)) != -1) return (1); if (errno == EINTR) goto again; if (errno == ECONNREFUSED) { /* * The caller gave up, but his invitation somehow * was not cleared. Clear it and initiate an * invitation. (We know there are no newer invitations, * the talkd works LIFO.) */ ctl_transact(his_machine_addr, msg, DELETE, &response); close(sockt); open_sockt(); return (0); } p_error("Unable to connect with initiator"); /*NOTREACHED*/ }
int check_local() { CTL_RESPONSE response; /* the rest of msg was set up in get_names */ msg.ctl_addr = ctl_addr; if (!look_for_invite(&response)) { /* we must be initiating a talk */ return (0); } /* * there was an invitation waiting for us, * so connect with the other (hopefully waiting) party */ current_state = gettext("Waiting to connect with caller"); response = swapresponse(response); while (connect(sockt, (struct sockaddr *)&response.addr, sizeof (response.addr)) != 0) { if (errno == ECONNREFUSED) { /* * the caller gave up, but the invitation somehow * was not cleared. Clear it and initiate an * invitation. (We know there are no newer invitations, * the talkd works LIFO.) */ ctl_transact(rem_machine_addr, msg, DELETE, &response); close(sockt); open_sockt(); return (0); } else if (errno == EINTR) { /* we have returned from an interupt handler */ continue; } else { p_error(gettext("Unable to connect with initiator")); } } return (1); }