Select the Connection?

Posted on 2006-05-09
Last Modified: 2010-04-05

Is it possible, using TCP, to select which network connection to use to send data to a remote server? By this I mean on my PC I can have a LAN connection and a Wireless LAN connection, or have a LAN connection and be connected to the internet on a datacard etc. Is there a way to select the connection I want to use to send the data, without disabling the other connections?

Question by:pixaya
    LVL 28

    Expert Comment

    well, what is your configureation in respect to HW?
    if you have different ip's for all connections then the routing will be the one to decide where the packets will be sent.

    that means that if you have an ip of 192.168.x.y on interface 1, and 10.42.42.x on interface 2 and default gateway is set to 192.168.a.b then all packets that are not in the 2 ip classes will be routed to 192.168.a.b by default.

    however, you should be able to bind (all network components have a localbind or bindaddress or something similar to whichever interface you want (specifiying the ip) in which case packets will be routed to the default gateway of that interface. I never tried this before as I never needed it (and never had 2 network interfaces either)
    if the above does not work and cannot be made to work, then one solution (ugly one) is to temporarely add a route entry (executing "route add ip mask gateway" command in worst case or using api) do the job and then removing the route.

    but I guess that since all components have that bind thing, that should work :)
    LVL 1

    Author Comment


    Thanks for the info. I kind of figured that if the interfaces had different IP ranges that the right interface would be used depending on the range of the IP I was sending to.

    As for the binding I will have a go with that later on.

    One thing I'm not so clear on though is say both connections/interfaces (not too sure on the correct terminology) have an internet connection, and the remote IP I want to send the data to is a public IP address running somewhere else in the world, how do make it use one connection rather than the other? Or is this the same scenario as above?

    The reason for this question is I would like to be able to use multiple datacards, via external drives, to send the data, there by increasing the amount of data I can send. I'm not even sure if this can be done but I find the idea very interesting and it would be beneficial to a project I am currently working on.
    LVL 28

    Accepted Solution

    well .. the thing with the routes will work for sure. but you will have to decide which ip goes to which interface. the binding thing should also work (at least in theory): since you bind to a certain interface (local ip), the connection should always send the data to teh interfaces defautl gateway and in the case that the interface does not have a default gateway assigned, then go to the defautl gateway of the main interface (first interface).
    but as I said, this is in theory that I haven't tested. but it should work as I said it.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Editing text in a Delphi stringgrid cell 8 227
    TTimer no longer functioning 7 64
    Convert Jpg /PNG To GIF 5 83
    Newbie Thread Programming 1 94
    In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
    Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now