project_files/frontlib/socket.c
changeset 8091 e0a76056a633
parent 7314 6171f0bad318
child 8094 6c5b4e69f03d
child 10017 de822cd3df3a
equal deleted inserted replaced
8090:38d9cc60b14c 8091:e0a76056a633
    82 			/* SDL_net does not seem to have a way to listen on a random unused port
    82 			/* SDL_net does not seem to have a way to listen on a random unused port
    83 			   and find out which port that is, so let's try to find one ourselves. */
    83 			   and find out which port that is, so let's try to find one ourselves. */
    84 			srand(time(NULL));
    84 			srand(time(NULL));
    85 			for(int i=0; !result->sock && i<1000; i++) {
    85 			for(int i=0; !result->sock && i<1000; i++) {
    86 				// IANA suggests using ports in the range 49152-65535 for things like this
    86 				// IANA suggests using ports in the range 49152-65535 for things like this
    87 				result->port = 49152+(rand()%(65535-49152));
    87 				result->port = 49152+(rand()%(65536-49152));
    88 				result->sock = listen(result->port);
    88 				result->sock = listen(result->port);
    89 			}
    89 			}
    90 		}
    90 		}
    91 		if(!result->sock) {
    91 		if(!result->sock) {
    92 			flib_log_e("Failed to create acceptor.");
    92 			flib_log_e("Failed to create acceptor.");