src/dps8/fnpuv.c
//
// Start a slave line connection listener.
//
Start a slave line connection listener.
Start a slave line connection listener .
void fnpuv_open_slave (uint fnpno, uint lineno)
  {
    if (! loop)
      return;
    sim_printf ("[FNP emulation: fnpuv_open_slave %d.%d]\n", fnpno, lineno);
    struct t_line * linep = & fnpUnitData[fnpno].MState.line[lineno];
    if (linep->server.data)
      return;
    uv_tcp_init (loop, & linep->server);
    uvClientData * p = (uvClientData *) malloc (sizeof (uvClientData));
    if (! p)
      {
         sim_warn ("uvClientData malloc failed\n");
         return;
      }
    p->assoc = false;
    p->nPos = 0;
    p->fnpno = fnpno;
    p->lineno = lineno;
    linep->server.data = p;
    linep->client = NULL;
    struct sockaddr_in addr;
    uv_ip4_addr ("0.0.0.0", linep->port, & addr);
    uv_tcp_bind (& linep->server, (const struct sockaddr *) & addr, 0);
    sim_printf ("[FNP emulation: listening on port %d]\n", linep->port);
    int r = uv_listen ((uv_stream_t *) & linep->server, DEFAULT_BACKLOG, 
                       on_new_connection);
    if (r)
     {
        sim_printf ("[FNP emulation: Listen error %s]\n", uv_strerror (r));
      }
#if 0
    linep->client = (uv_tcp_t *) malloc (sizeof (uv_tcp_t));
    uv_tcp_init (loop, linep->client);
    uvClientData * p = (uvClientData *) malloc (sizeof (uvClientData));
    if (! p)
      {
         sim_warn ("uvClientData malloc failed\n");
         return;
      }
    p->assoc = false;
    p->telnetp = NULL;
    p->fnpno = fnpno;
    p->lineno = lineno;
    linep->client->data = p;
    struct sockaddr_in addr;
    uv_ip4_addr ("0.0.0.0", linep->port, & addr);
    uv_tcp_bind (linep->client, (const struct sockaddr *) & addr, 0);
sim_printf ("listening on port %d\n", linep->port);
    int r = uv_listen ((uv_stream_t *) linep->client, DEFAULT_BACKLOG, 
                       on_slave_connect);
    if (r)
     {
        fprintf (stderr, "Listen error %s\n", uv_strerror (r));
      }
#endif
  }
void fnpuv_open_slave ( uint fnpno , uint lineno ) { if ( ! loop ) return ; sim_printf ( " \n " , fnpno , lineno ) ; struct t_line * linep = & fnpUnitData [ fnpno ] . MState . line [ lineno ] ; if ( linep -> server . data ) return ; uv_tcp_init ( loop , & linep -> server ) ; uvClientData * p = ( uvClientData * ) malloc ( sizeof ( uvClientData ) ) ; if ( ! p ) { sim_warn ( " \n " ) ; return ; } p -> assoc = false ; p -> nPos = 0 ; p -> fnpno = fnpno ; p -> lineno = lineno ; linep -> server . data = p ; linep -> client = NULL ; struct sockaddr_in addr ; uv_ip4_addr ( " " , linep -> port , & addr ) ; uv_tcp_bind ( & linep -> server , ( const struct sockaddr * ) & addr , 0 ) ; sim_printf ( " \n " , linep -> port ) ; int r = uv_listen ( ( uv_stream_t * ) & linep -> server , DEFAULT_BACKLOG , on_new_connection ) ; if ( r ) { sim_printf ( " \n " , uv_strerror ( r ) ) ; } #if 0 linep -> client = ( uv_tcp_t * ) malloc ( sizeof ( uv_tcp_t ) ) ; uv_tcp_init ( loop , linep -> client ) ; uvClientData * p = ( uvClientData * ) malloc ( sizeof ( uvClientData ) ) ; if ( ! p ) { sim_warn ( " \n " ) ; return ; } p -> assoc = false ; p -> telnetp = NULL ; p -> fnpno = fnpno ; p -> lineno = lineno ; linep -> client -> data = p ; struct sockaddr_in addr ; uv_ip4_addr ( " " , linep -> port , & addr ) ; uv_tcp_bind ( linep -> client , ( const struct sockaddr * ) & addr , 0 ) ; sim_printf ( " \n " , linep -> port ) ; int r = uv_listen ( ( uv_stream_t * ) linep -> client , DEFAULT_BACKLOG , on_slave_connect ) ; if ( r ) { fprintf ( stderr , " \n " , uv_strerror ( r ) ) ; } #endif }
Start a slave line connection listener.
Start a slave line connection listener .
// Do we already have a listening port (ie not first time)? // Mark this server has being a slave server // XXX This does not get freed during a normal shutdown, as Multics // XXX doesn't tell idle slave lines anything. The emulator shutdown // XXX needs to call an FNP cleanup routine that frees this. // It should be possible to run a peer-to-peer TCP instead of client server, // but it's not clear to me.