tests: SocketTests: Pick OS-assigned instead of setting one manually

This fixes failures if the port is already being taken by other apps or
if this test is run several times concurrently in the same system.

Change-Id: Iea213375e489a56cf8ed3e47fe814e17c288803e
diff --git a/tests/CommonLibs/SocketsTest.cpp b/tests/CommonLibs/SocketsTest.cpp
index 235b8f3..9a7d6f0 100644
--- a/tests/CommonLibs/SocketsTest.cpp
+++ b/tests/CommonLibs/SocketsTest.cpp
@@ -35,14 +35,14 @@
 static const int gNumToSend = 10;
 
 
-void *testReaderIP(void *)
+void *testReaderIP(void *param)
 {
-	UDPSocket readSocket("127.0.0.1", 5934, "localhost", 5061);
-	readSocket.nonblocking();
+	UDPSocket *readSocket = (UDPSocket *)param;
+	readSocket->nonblocking();
 	int rc = 0;
 	while (rc<gNumToSend) {
 		char buf[MAX_UDP_LENGTH];
-		int count = readSocket.read(buf, MAX_UDP_LENGTH);
+		int count = readSocket->read(buf, MAX_UDP_LENGTH);
 		if (count>0) {
 			CERR("read: " << buf);
 			rc++;
@@ -56,12 +56,13 @@
 int main(int argc, char * argv[] )
 {
 
+  UDPSocket readSocket("127.0.0.1", 0);
+  UDPSocket socket1("127.0.0.1", 0, "localhost", readSocket.port());
+
+  CERR("socket1: " << socket1.port() << ", readSocket: " << readSocket.port());
+
   Thread readerThreadIP;
-  readerThreadIP.start(testReaderIP,NULL);
-
-  UDPSocket socket1("127.0.0.1", 5061, "127.0.0.1", 5934);
-
-  CERR("socket1: " << socket1.port());
+  readerThreadIP.start(testReaderIP, &readSocket);
 
   // give the readers time to open
   sleep(1);