Annotation of cci/usr/src/ucb/talk/ctl.c, revision 1.1

1.1     ! root        1: /* $Header: ctl.c,v 1.2 85/01/09 13:04:43 rcs Exp $ */
        !             2: 
        !             3: /* This file handles haggling with the various talk daemons to
        !             4:    get a socket to talk to. sockt is opened and connected in
        !             5:    the progress
        !             6:  */
        !             7: 
        !             8: #include "talk_ctl.h"
        !             9: 
        !            10: struct sockaddr_in daemon_addr = { AF_INET };
        !            11: struct sockaddr_in ctl_addr = { AF_INET };
        !            12: struct sockaddr_in my_addr = { AF_INET };
        !            13: 
        !            14:     /* inet addresses of the two machines */
        !            15: struct in_addr my_machine_addr;
        !            16: struct in_addr his_machine_addr;
        !            17: 
        !            18: u_short daemon_port;   /* port number of the talk daemon */
        !            19: 
        !            20: int ctl_sockt;
        !            21: int sockt;
        !            22: int invitation_waiting = 0;
        !            23: 
        !            24: CTL_MSG msg;
        !            25: 
        !            26: open_sockt()
        !            27: {
        !            28:     int length;
        !            29: 
        !            30:     my_addr.sin_addr = my_machine_addr;
        !            31:     my_addr.sin_port = 0;
        !            32: 
        !            33:     sockt = socket(AF_INET, SOCK_STREAM, 0, 0);
        !            34: 
        !            35:     if (sockt <= 0) {
        !            36:        p_error("Bad socket");
        !            37:     }
        !            38: 
        !            39:     if ( bind(sockt, &my_addr, sizeof(my_addr)) != 0) {
        !            40:        p_error("Binding local socket");
        !            41:     }
        !            42: 
        !            43:     length = sizeof(my_addr);
        !            44: 
        !            45:     if (getsockname(sockt, &my_addr, &length) == -1) {
        !            46:        p_error("Bad address for socket");
        !            47:     }
        !            48: 
        !            49: }
        !            50: 
        !            51:     /* open the ctl socket */
        !            52: 
        !            53: open_ctl() 
        !            54: {
        !            55:     int length;
        !            56: 
        !            57:     ctl_addr.sin_port = 0;
        !            58:     ctl_addr.sin_addr = my_machine_addr;
        !            59: 
        !            60:     ctl_sockt = socket(AF_INET, SOCK_DGRAM, 0, 0);
        !            61: 
        !            62:     if (ctl_sockt <= 0) {
        !            63:        p_error("Bad socket");
        !            64:     }
        !            65: 
        !            66:     if (bind(ctl_sockt, &ctl_addr, sizeof(ctl_addr), 0) != 0) {
        !            67:        printf("Address is: ");
        !            68:        print_addr(ctl_addr);
        !            69:        p_error("Couldn't bind to control socket");
        !            70:     }
        !            71: 
        !            72:     length = sizeof(ctl_addr);
        !            73:     if (getsockname(ctl_sockt, &ctl_addr, &length) == -1) {
        !            74:        p_error("Bad address for ctl socket");
        !            75:     }
        !            76: }
        !            77: 
        !            78: /* print_addr is a debug print routine. moved to print.c */
        !            79: /*
        !            80: /*print_addr(addr)
        !            81: /*struct sockaddr_in addr;
        !            82: /*{
        !            83: /*    int i;
        !            84: /*
        !            85: /*    printf("addr = %x, port = %o, family = %o zero = ",
        !            86: /*         addr.sin_addr, addr.sin_port, addr.sin_family);
        !            87: /*
        !            88: /*    for (i = 0; i<8;i++) {
        !            89: /*     printf("%o ", (int)addr.sin_zero[i]);
        !            90: /*    }
        !            91: /*    putchar('\n');
        !            92: /*}
        !            93: /**/

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.