int doconn() { for ( int i=0; i<1000; i++ ) { int ret; int sock = mysock(); if (sock == -1 ) return -1; ret = myconnect(sock,(char*)"127.0.0.1",6666); //if ( ret == -1 ) // return -1; //twrite((void*)sock); } printf("pid %d sleep\n",getpid()); sleep(60000); }
static void link_out () { LINK *link; NR_NODE *np; CIRCUIT *circuit; SADDR addr; word s; link = (LINK *)p; if (MemLow) { link->flags = p_nil; return; } puser(link->alias); // See if the requested destination is a known alias or call, // use it if it is. Otherwise give up. np = nr_findca(link->call); if (!np) { link->flags = p_nil; return; } s = socket(TYPE_NETROM); mysock(s); flushoff(s); // The RT control process will do the flush. // Set up the local and remote addresses. addr.type = TYPE_NETROM; memcpy(addr.a.nr.user, Node->call, ln_call+1); memcpy(addr.a.nr.node, Node->call, ln_call+1); bind(s, &addr); memcpy(addr.a.nr.user, np->call, ln_call+1); memcpy(addr.a.nr.node, np->call, ln_call+1); if (!connect(s, &addr)) { link->flags = p_nil; return; } // Create a circuit for this link. circuit = circuit_new(p_linkini, s); if (!circuit) { link->flags = p_nil; return; } circuit->u.link = link; tputs("*RTL\n"); // Log in to the remote RT system. // Run in circles, scream and shout. for (;;) if (getinp(circuit)) { if (circuit->flags & p_linked) chkctl(circuit); else { if (!matchi(circuit->buf, "OK")) { link_drop(circuit); link->flags = p_nil; return; } link->flags = p_linked; circuit->flags = p_linked; state_tell(circuit); } } else { link_drop(circuit); link->flags = p_nil; return; } }