Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3661490
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:18:39+00:00 2026-05-19T01:18:39+00:00

I have a computer with a few different internet connections. LAN, WLAN, WiFi or

  • 0

I have a computer with a few different internet connections. LAN, WLAN, WiFi or 3G. All of these are active and the machine can use any of them.

Now I want to tell my application to use one of the available connections. For example I want to tell my application to use only WiFi while other software might use something else.

In my c# application I use classes like HttpWebRequest and HttpWebResponse.

Is this even possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T01:18:40+00:00Added an answer on May 19, 2026 at 1:18 am

    This is somewhat advanced functionality which is abstracted away by both HttpWebRequest, WebRequest, WebClient and the like. You can, however, do this using TcpClient (using the constructor taking a local endpoint) or using sockets and calling Socket.Bind.

    Use the Bind method if you need to use a specific local endpoint. You must call Bind before you can call the Listen method. You do not need to call Bind before using the Connect method unless you need to use a specific local endpoint.

    Bind to a local endpoint for the interface you want to use. If your local machine have ip address 192.168.0.10 for the WiFi address, then using that a local endpoint will force sockets to use that interface. Default is unbound (really 0.0.0.0) which tells the network stack to resolve the interface automatically, which you want to circumvent.

    Here’s some example code based on Andrew’s comment. Note that specifying 0 as local endpoint port means that it is dynamic.

    using System.Net;
    using System.Net.Sockets;
    
    public static class ConsoleApp
    {
        public static void Main()
        {
            {
                // 192.168.20.54 is my local network with internet accessibility
                var localEndPoint = new IPEndPoint(IPAddress.Parse("192.168.20.54"), port: 0);
                var tcpClient = new TcpClient(localEndPoint);
    
                // No exception thrown.
                tcpClient.Connect("stackoverflow.com", 80);
            }
            {
                // 192.168.2.49 is my vpn, having no default gateway and unable to forward
                // packages to anything that is outside of 192.168.2.x
                var localEndPoint = new IPEndPoint(IPAddress.Parse("192.168.2.49"), port: 0);
                var tcpClient = new TcpClient(localEndPoint);
    
                // SocketException: A socket operation was attempted to an unreachable network 64.34.119.12:80
                tcpClient.Connect("stackoverflow.com", 80);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We currently have a few products for which the licensing depends on the computer
I have computer (ubuntu server). Server have internet and share internet for local network.
I have a few related applications that I want to deploy to different computers.
I have tried a few different ways to display wName, wContact with no luck
In my application, I've got a few different types of entities that I have
We have a few tables with persisted computed columns in SQL Server. Is there
I have turned computer monitor off using this command SendMessage(f.Handle, WM_SYSCOMMAND, (IntPtr)SC_MONITORPOWER, (IntPtr)(turnOff ?
I have two computer : the desktop in my company and the portable computer
I have a computer that's configured for magic WOL packets, so the adapter will
I only have one computer (running OS X), and need to test in both

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.