About Store Forum Documentation Contact
Donations:
289$/mo



Post Reply 
Supporting Network Adapter Selection
Author Message
aceio76 Offline
Silver Supporter

Post: #1
Supporting Network Adapter Selection
Esenthel,

Would it be possible to expose the list of available IP network adapters/interfaces and also be able to attach the selected network interface to either Connection or FastConnection? Currently, it looks like it binds to the first network interface it sees.

Thanks.
(This post was last modified: 03-02-2014 02:43 AM by aceio76.)
03-02-2014 02:41 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Supporting Network Adapter Selection
Hi,
Could you tell me why do you need this?
Is the detected address not ok?
Thanks
03-02-2014 09:23 AM
Find all posts by this user Quote this message in a reply
aceio76 Offline
Silver Supporter

Post: #3
RE: Supporting Network Adapter Selection
Hi Esenthel,

The scenarios really center around computers with multiple network adapters. For my case, it's not really about desktop computers but laptops, since in many cases they have more than 2 network adapters like one for wireless and one for the wired local network. When the application runs, it seems to detect the first interface (in this case, the wireless) where the preferred interface is the wired network. Such is the case for LAN gaming where folks connect the wireless for internet access while using the wired network for multiplayer gaming. Also, there are a number of situations where a removable network adapter (USB-based adapter in many cases) is plugged to the laptop and that is the desired interface and there is no way to select that manually through the game. Another scenario that I came across is with my NAT punchthrough where Connection does pick the correct IP (the right network adapter is wireless in this case), but for the FastConnection it picks up and uses the wired network where it isn't routable out to the internet. The scenarios described so far can be circumvented by simply disabling the undesired network adapters (wired/wireless/removable depending on what is needed), but the biggest need I see is to be able to assign network adapters to Connection/FastConnection on Server side applications, where the server computer has several network interfaces and multiple Esenthel applications need to run on the same computer but each application needs to utilize specific network interfaces.

If you're also curious about where the multiplayer LAN scenarios are being observed, it's on game events at the local Microsoft Stores (https://content.microsoftstore.com/en-us/events) where people bring their own laptops (and sometimes desktop PCs) and play multiplayer games with each other. You can request a particular store to host a specific game and everyone will come and play that game for an hour or so. It's a good way to promote your product (and test it as well), and since these Microsoft Stores talk to each other, you have a good chance of spreading the word about your game.
(This post was last modified: 03-02-2014 03:28 PM by aceio76.)
03-02-2014 03:13 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Supporting Network Adapter Selection
I could add a function that would enumerate all local IP's.
But this would give you only a list of addresses:
Memc<SockAddr> sa;
How would you know wchich one to choose from that?

For windows I'm using
if(!GetAddrInfoA(Str8(host), Str8(TextInt(port)), &hints, &result))
to enumerate the addresses, which give ADDRINFOA
Code:
typedef struct addrinfo
{
    int                 ai_flags;       // AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST
    int                 ai_family;      // PF_xxx
    int                 ai_socktype;    // SOCK_xxx
    int                 ai_protocol;    // 0 or IPPROTO_xxx for IPv4 and IPv6
    size_t              ai_addrlen;     // Length of ai_addr
    char *              ai_canonname;   // Canonical name for nodename
    __field_bcount(ai_addrlen) struct sockaddr *   ai_addr;        // Binary address
    struct addrinfo *   ai_next;        // Next structure in linked list
}
ADDRINFOA, *PADDRINFOA;
and I extract it like that:
Code:
switch(r->ai_family)
      {
         case AF_INET:
            if(r->ai_addr && r->ai_addrlen==SIZE(address))
            {
               sockaddr_in &temp=*(sockaddr_in*)r->ai_addr;
               if(!ok || temp.sin_addr.s_addr!=16777343){address=temp; ok=true;} // skip replacing with "127.0.0.1" localhost
            }
         break;
I wasn't able to find any useful information about the type of connection.

And when it comes to using specific address for Connection/FastConnection, currently I'm using
Code:
Bool FastConnection::create(Int port)
{..
  if(_socket.bind(SockAddr().setServer(port)))
and
Code:
SockAddr& SockAddr::setServer(Int port)
{
   Zero(address);
   address.sin_family     =AF_INET;
   address.sin_addr.s_addr=htonl(INADDR_ANY);
   address.sin_port       =htons(port);
   return T;
}
Would just replacing "htonl(INADDR_ANY);" with a specific local IP would work?
03-02-2014 10:17 PM
Find all posts by this user Quote this message in a reply
aceio76 Offline
Silver Supporter

Post: #5
RE: Supporting Network Adapter Selection
I think if Connection/FastConnection can be bound to a specific socket addr.sin_addr.s_addr (one that is bound to a specific network interface), it might be enough. I think it would be simpler if users only see a list of IP addresses to use as the connection, rather than the typically cryptic Network Adapter names. Being able to expose the list of ip addresses would allow that list to be used as the selection to connect with Connection/FastConnection.

I was looking at this as reference:
http://www.codeproject.com/Articles/4004...Helper-API

But I'd rather avoid displaying Network Adapter names to users, just what IP addresses are used on their device/computer might be better.
03-03-2014 06:51 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: Supporting Network Adapter Selection
Next release will include these additions:
-added new methods FastConnection and ConnectionServer that allow to create them on a custom address
-added new functions GetLocalAddresses and GetHostAddresses
03-08-2014 05:34 AM
Find all posts by this user Quote this message in a reply
aceio76 Offline
Silver Supporter

Post: #7
RE: Supporting Network Adapter Selection
Thank you very much esenthel.
03-08-2014 07:12 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #8
RE: Supporting Network Adapter Selection
Once this becomes available, please let me know if it actually helps (if it's really needed).
As I'm curious if the INADDR_ANY currently used in 'setServer' isn't already the best choice, which allows the OS to autodetect the best connection.
03-11-2014 04:19 AM
Find all posts by this user Quote this message in a reply
aceio76 Offline
Silver Supporter

Post: #9
RE: Supporting Network Adapter Selection
I sure will, Esenthel. It might take me a while to fully confirm this, but I can tell right now, the ability to select what network to attach to a Connection or FastConnection is definitely a needed feature. Even right now, I have no ability to select the right network adapter on my server code when I need to point a Connection/FastConnection object to an internal network and another Connection/FastConnection object to the internet-facing network.
03-12-2014 10:54 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply