* ---------------------|--------------------------------------------------------------
* CAPS or CAPABILITY | capability strings.
* IP or HOST | IP address of the node to accept connection from other node.
- * PORT | Port of the node to accept connection from other node. The value should be 0 or higher.
+ * PORT | Port of the node to accept connection from other node. The value should be 0 or higher, if the port is set to 0 then the available port is allocated.
* DEST_IP or DEST_HOST | IP address of the destination node. In case of TCP connection, it is the IP address of the destination node, and in the case of Hybrid or AITT connection, it is the IP address of the broker.
* DEST_PORT | Port of the destination node. In case of TCP connection, it is the port number of the destination node, and in the case of Hybrid or AITT connection, it is the port number of the broker. The value should be 0 or higher.
* TOPIC | Topic used to publish/subscribe to/from the broker.
port = (int) strtoll (port_str, NULL, 10);
+ if (port == 0) {
+ port = nns_edge_get_available_port ();
+ }
+
if (!PORT_IS_VALID (port)) {
nns_edge_loge ("Invalid port number %d.", port);
port = -1;
ret = nns_edge_aitt_create (&handle);
EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE);
- ret = nns_edge_aitt_connect (handle, "temp-aitt-id", "temp-aitt-topic", "127.0.0.1", 0);
+ ret = nns_edge_aitt_connect (handle, "temp-aitt-id", "temp-aitt-topic", "127.0.0.1", -1);
EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
ret = nns_edge_aitt_close (handle);
/* Invalid port number */
ret = nns_edge_set_info (edge_h, "port", "-1");
EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
- ret = nns_edge_set_info (edge_h, "port", "0");
- EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);
ret = nns_edge_set_info (edge_h, "port", "77777");
EXPECT_NE (ret, NNS_EDGE_ERROR_NONE);