Changeset 3732:4525972e9c84 in roaraudio


Ignore:
Timestamp:
04/25/10 22:36:06 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added support to pass listen sockets

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/roaraudio/client.h

    r3683 r3732  
    5959#endif 
    6060 
     61#define ROAR_CLIENTPASS_FLAG_NONE    0x0000 
     62#define ROAR_CLIENTPASS_FLAG_LISTEN  0x0001 
     63 
    6164#endif 
    6265 
  • roard/req.c

    r3729 r3732  
    294294 int sock = clients_get_fh(client); 
    295295 int16_t * d = (int16_t*)mes->data; 
     296 struct roard_listen * lsock; 
     297 int listening; 
    296298 int fh; 
    297299 int i; 
     
    332334  return -1; 
    333335 
     336 listening = d[1] & ROAR_CLIENTPASS_FLAG_LISTEN; 
     337 
     338 if ( listening ) 
     339  d[1] -= ROAR_CLIENTPASS_FLAG_LISTEN; 
     340 
    334341 if ( d[1] != 0 ) // flags 
    335342  return -1; 
    336343 
    337  if ( d[2] != ROAR_PROTO_ROARAUDIO ) // protocol 
    338   return -1; 
    339  
    340  if ( d[3] != ROAR_BYTEORDER_NETWORK ) // byte order 
    341   return -1; 
    342  
    343  if ( (client = clients_new()) == -1 ) 
    344   return -1; 
    345  
    346  if ( clients_set_fh(client, fh) == -1 ) { 
    347   clients_delete(client); 
    348   return -1; 
    349  } 
    350  
    351  if ( clients_get(client, &c) != -1 ) { 
    352   roar_nnode_new_from_fh(&(c->nnode), fh, 1); 
     344 if ( listening ) { 
     345  if ( get_listen(&lsock, NULL) == -1 ) 
     346   return -1; 
     347 
     348  lsock->socket = fh; 
     349  lsock->proto  = d[2]; 
     350 } else { 
     351  if ( d[2] != ROAR_PROTO_ROARAUDIO ) // protocol 
     352   return -1; 
     353 
     354  if ( d[3] != ROAR_BYTEORDER_NETWORK ) // byte order 
     355   return -1; 
     356 
     357  if ( (client = clients_new()) == -1 ) 
     358   return -1; 
     359 
     360  if ( clients_set_fh(client, fh) == -1 ) { 
     361   clients_delete(client); 
     362   return -1; 
     363  } 
     364 
     365  if ( clients_get(client, &c) != -1 ) { 
     366   roar_nnode_new_from_fh(&(c->nnode), fh, 1); 
     367  } 
    353368 } 
    354369 
Note: See TracChangeset for help on using the changeset viewer.