@@ -1592,16 +1592,21 @@ int startControlStream(void) {
1592
1592
int err ;
1593
1593
1594
1594
if (AppVersionQuad [0 ] >= 5 ) {
1595
- ENetAddress address ;
1595
+ ENetAddress remoteAddress , localAddress ;
1596
1596
ENetEvent event ;
1597
1597
1598
1598
LC_ASSERT (ControlPortNumber != 0 );
1599
1599
1600
- enet_address_set_address (& address , (struct sockaddr * )& RemoteAddr , AddrLen );
1601
- enet_address_set_port (& address , ControlPortNumber );
1600
+ enet_address_set_address (& localAddress , (struct sockaddr * )& LocalAddr , AddrLen );
1601
+ enet_address_set_port (& localAddress , 0 ); // Wildcard port
1602
+
1603
+ enet_address_set_address (& remoteAddress , (struct sockaddr * )& RemoteAddr , AddrLen );
1604
+ enet_address_set_port (& remoteAddress , ControlPortNumber );
1602
1605
1603
1606
// Create a client
1604
- client = enet_host_create (address .address .ss_family , NULL , 1 , CTRL_CHANNEL_COUNT , 0 , 0 );
1607
+ client = enet_host_create (RemoteAddr .ss_family ,
1608
+ LocalAddr .ss_family != 0 ? & localAddress : NULL ,
1609
+ 1 , CTRL_CHANNEL_COUNT , 0 , 0 );
1605
1610
if (client == NULL ) {
1606
1611
stopping = true;
1607
1612
return -1 ;
@@ -1616,7 +1621,7 @@ int startControlStream(void) {
1616
1621
enet_socket_set_option (client -> socket , ENET_SOCKOPT_QOS , 1 );
1617
1622
1618
1623
// Connect to the host
1619
- peer = enet_host_connect (client , & address , CTRL_CHANNEL_COUNT , 0 );
1624
+ peer = enet_host_connect (client , & remoteAddress , CTRL_CHANNEL_COUNT , 0 );
1620
1625
if (peer == NULL ) {
1621
1626
stopping = true;
1622
1627
enet_host_destroy (client );
0 commit comments