Changeset 3293:f8b44412b38d in roaraudio
- Timestamp:
- 02/01/10 21:32:50 (14 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- libroar
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libroar/vio_dstr.c
r3292 r3293 204 204 break; 205 205 case ROAR_VIO_DEF_TYPE_SOCKET: 206 if ( roar_vio_open_def_socket(calls, def ) == -1 )206 if ( roar_vio_open_def_socket(calls, def, opts) == -1 ) 207 207 return -1; 208 208 break; -
libroar/vio_socket.c
r1650 r3293 39 39 #endif 40 40 41 int roar_vio_open_def_socket (struct roar_vio_calls * calls, struct roar_vio_defaults * def ) {41 int roar_vio_open_def_socket (struct roar_vio_calls * calls, struct roar_vio_defaults * def, char * opts) { 42 42 #ifdef _CAN_OPERATE 43 43 int fh = -1; 44 44 socklen_t len = 0; 45 int listening = 0; 46 int one_client = 0; 47 int client; 45 48 46 49 if ( calls == NULL || def == NULL ) 47 50 return -1; 51 52 if ( opts != NULL ) { 53 if ( strstr(opts, "listen") != NULL ) { 54 listening = 1; 55 one_client = 1; 56 } 57 } 48 58 49 59 if ( def->type != ROAR_VIO_DEF_TYPE_SOCKET ) … … 132 142 return -1; 133 143 134 if ( connect(fh, &(def->d.socket.sa.sa), len) == -1 ) { 135 close(fh); 136 return -1; 144 if ( listening ) { 145 if ( bind(fh, &(def->d.socket.sa.sa), len) == -1 ) { 146 close(fh); 147 return -1; 148 } 149 150 if ( listen(fh, one_client ? 1 : 16) == -1 ) { 151 close(fh); 152 return -1; 153 } 154 155 if ( one_client ) { 156 client = accept(fh, NULL, NULL); 157 close(fh); 158 159 if ( client == -1 ) { 160 return -1; 161 } 162 163 fh = client; 164 } 165 } else { 166 if ( connect(fh, &(def->d.socket.sa.sa), len) == -1 ) { 167 close(fh); 168 return -1; 169 } 137 170 } 138 171
Note: See TracChangeset
for help on using the changeset viewer.