Allow explicit UDP port option, confine ports to range 60000..61000

This commit is contained in:
Keith Winstein
2012-03-10 03:34:47 -05:00
parent c96e4956b0
commit df3eec1397
9 changed files with 142 additions and 32 deletions
+6 -1
View File
@@ -74,6 +74,11 @@ namespace Network {
static const uint64_t MIN_RTO = 50; /* ms */
static const uint64_t MAX_RTO = 1000; /* ms */
static const int PORT_RANGE_LOW = 60001;
static const int PORT_RANGE_HIGH = 60999;
static bool try_bind( int socket, uint32_t s_addr, int port );
int sock;
bool has_remote_addr;
struct sockaddr_in remote_addr;
@@ -100,7 +105,7 @@ namespace Network {
Packet new_packet( string &s_payload );
public:
Connection( const char *desired_ip ); /* server */
Connection( const char *desired_ip, const char *desired_port ); /* server */
Connection( const char *key_str, const char *ip, int port ); /* client */
void send( string s );