|
|
1.1 ! root 1: /* $Header: look_up.c 1.2 83/03/28 00:34:22 moore Exp $ */ ! 2: ! 3: #include "talk_ctl.h" ! 4: ! 5: /* see if the local daemon has a invitation for us */ ! 6: ! 7: check_local() ! 8: { ! 9: CTL_RESPONSE response; ! 10: ! 11: /* the rest of msg was set up in get_names */ ! 12: ! 13: msg.ctl_addr = ctl_addr; ! 14: ! 15: if (!look_for_invite(&response)) { ! 16: ! 17: /* we must be initiating a talk */ ! 18: ! 19: return(0); ! 20: } ! 21: ! 22: /* ! 23: * there was an invitation waiting for us, ! 24: * so connect with the other (hopefully waiting) party ! 25: */ ! 26: ! 27: current_state = "Waiting to connect with caller"; ! 28: ! 29: while (connect(sockt, &response.addr, sizeof(response.addr)) != 0) { ! 30: if (errno == ECONNREFUSED) { ! 31: ! 32: /* the caller gave up, but his invitation somehow ! 33: * was not cleared. Clear it and initiate an ! 34: * invitation. (We know there are no newer invitations, ! 35: * the talkd works LIFO.) ! 36: */ ! 37: ! 38: ctl_transact(his_machine_addr, msg, DELETE, &response); ! 39: close(sockt); ! 40: open_sockt(); ! 41: return(0); ! 42: } else if (errno == EINTR) { ! 43: /* we have returned from an interupt handler */ ! 44: continue; ! 45: } else { ! 46: p_error("Unable to connect with initiator"); ! 47: } ! 48: } ! 49: ! 50: return(1); ! 51: } ! 52: ! 53: /* look for an invitation on 'machine' */ ! 54: ! 55: look_for_invite(response) ! 56: CTL_RESPONSE *response; ! 57: { ! 58: struct in_addr machine_addr; ! 59: ! 60: current_state = "Checking for invitation on caller's machine"; ! 61: ! 62: ctl_transact(his_machine_addr, msg, LOOK_UP, response); ! 63: ! 64: /* the switch is for later options, such as multiple ! 65: invitations */ ! 66: ! 67: switch (response->answer) { ! 68: ! 69: case SUCCESS: ! 70: ! 71: msg.id_num = response->id_num; ! 72: return(1); ! 73: ! 74: default : ! 75: /* there wasn't an invitation waiting for us */ ! 76: return(0); ! 77: } ! 78: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.