Changeset 2530:921f7ac0be31 in roaraudio for roard/network.c


Ignore:
Timestamp:
09/02/09 00:50:34 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added support for multi homed server

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roard/network.c

    r2529 r2530  
    4040 fd_set sl; 
    4141 struct timeval tv; 
     42 int i; 
     43 int max_fh = -1; 
    4244 
    4345 FD_ZERO(&sl); 
    44  FD_SET(g_listen_socket, &sl); 
     46 
     47 for (i = 0; i < ROAR_MAX_LISTEN_SOCKETS; i++) { 
     48  if ( g_listen_socket[i] != -1 ) { 
     49   if ( g_listen_socket[i] > max_fh ) 
     50    max_fh = g_listen_socket[i]; 
     51 
     52   FD_SET(g_listen_socket[i], &sl); 
     53  } 
     54 } 
     55 
     56 if ( max_fh == -1 ) 
     57  return 0; 
    4558 
    4659 tv.tv_sec  = 0; 
    4760 tv.tv_usec = 1; 
    4861 
    49  if ((r = select(g_listen_socket + 1, &sl, NULL, NULL, &tv)) > 0) { 
     62 if ((r = select(max_fh + 1, &sl, NULL, NULL, &tv)) > 0) { 
    5063  ROAR_DBG("net_check_listen(void): We have a connection!"); 
    51   return net_get_new_client(); 
     64  for (i = 0; i < ROAR_MAX_LISTEN_SOCKETS; i++) { 
     65   if ( g_listen_socket[i] != -1 ) { 
     66    if ( FD_ISSET(g_listen_socket[i], &sl) ) { 
     67     if ( net_get_new_client(g_listen_socket[i], g_listen_proto[i]) == -1 ) 
     68      return -1; 
     69    } 
     70   } 
     71  } 
    5272 } 
    5373 
     
    5979 
    6080#ifdef _CAN_OPERATE 
    61 int net_get_new_client (void) { 
     81int net_get_new_client (int sock, int proto) { 
    6282 int fh; 
    6383 int client; 
     
    7191 struct roar_vio_calls vio; 
    7292 
    73  fh = accept(g_listen_socket, NULL, NULL); 
     93 fh = accept(sock, NULL, NULL); 
    7494 
    7595 ROAR_DBG("net_get_new_client(void): fh = %i", fh); 
     
    107127#endif 
    108128 
    109  if ( clients_set_proto(client, ROAR_PROTO_ESOUND) == -1 ) 
     129 ROAR_DBG("net_get_new_client(*): proto=0x%.4x", proto); 
     130 
     131 if ( clients_set_proto(client, proto) == -1 ) 
    110132  return -1; 
    111133 
    112  if ( roar_vio_open_fh(&vio, fh) == -1 ) 
    113   return -1; 
     134 switch (proto) { 
     135  case ROAR_PROTO_ESOUND: 
     136    if ( roar_vio_open_fh(&vio, fh) == -1 ) 
     137     return -1; 
    114138 
    115  if ( emul_esd_exec_command(client, ESD_PROTO_CONNECT, &vio) == -1 ) 
    116   return -1; 
     139    if ( emul_esd_exec_command(client, ESD_PROTO_CONNECT, &vio) == -1 ) 
     140     return -1; 
     141   break; 
     142 } 
    117143 
    118144// close(fh); 
Note: See TracChangeset for help on using the changeset viewer.