Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Interface selection  (Read 2408 times)

0 Members and 1 Guest are viewing this topic.

Danetta

  • Newbie
  • *
  • Posts: 11
    • View Profile
Interface selection
« on: September 02, 2016, 05:26:45 pm »
Hello.

How is it possible to select which network interface to use?
I have multiple VPNs installed, Hamachi for example (25.0.0.0)
It is the first one in priority list in my "network adapters" window on Win7.
However, when I use sockets in SFML, it still uses my "local interface", which is 192.168.etc.etc.

Some games I saw are always using local interface, some of them are using the first one in priority list, some of them allow player/user to choose which one to use.

How is it handled in SFML?
I looked through docemntation, but haven't found anything about it.
Google did not help too, probably because I don't know how to phrase my question properly.

Thank you.
« Last Edit: September 02, 2016, 08:37:07 pm by Danetta »

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Interface selection
« Reply #1 on: September 13, 2016, 08:42:31 am »
You can listen to a specific interface only using the optional parameter to sf::TcpListener::listen() or sf::UdpSocket::bind() respectively.

By default they'll listen on 0.0.0.0, which essentially means "any interface".
« Last Edit: December 05, 2016, 09:08:41 am by Mario »

Danetta

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Interface selection
« Reply #2 on: December 04, 2016, 06:46:56 pm »
Just having the same questiong, but about TCP_Socket. Decide to not create another topic and just use this one again.
UDP Socket has bind function which can be used, but what about TCP?
When I use "connect" I can only specify the address and port of server I need connect to. How can I select an interface which client should use in case I have multiple of them?

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Interface selection
« Reply #3 on: December 05, 2016, 09:09:49 am »
Short answer: You can't. The correct interface to use is determined by network topology and this happens outside your program. You can only specify which interface you want to listen on for incoming connections. You don't have any control for outgoing traffic.