Changeset 2530:921f7ac0be31 in roaraudio for roard/network.c
- Timestamp:
- 09/02/09 00:50:34 (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
roard/network.c
r2529 r2530 40 40 fd_set sl; 41 41 struct timeval tv; 42 int i; 43 int max_fh = -1; 42 44 43 45 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; 45 58 46 59 tv.tv_sec = 0; 47 60 tv.tv_usec = 1; 48 61 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) { 50 63 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 } 52 72 } 53 73 … … 59 79 60 80 #ifdef _CAN_OPERATE 61 int net_get_new_client ( void) {81 int net_get_new_client (int sock, int proto) { 62 82 int fh; 63 83 int client; … … 71 91 struct roar_vio_calls vio; 72 92 73 fh = accept( g_listen_socket, NULL, NULL);93 fh = accept(sock, NULL, NULL); 74 94 75 95 ROAR_DBG("net_get_new_client(void): fh = %i", fh); … … 107 127 #endif 108 128 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 ) 110 132 return -1; 111 133 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; 114 138 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 } 117 143 118 144 // close(fh);
Note: See TracChangeset
for help on using the changeset viewer.