socket programming on windows

Posted on 2005-04-09
Last Modified: 2010-04-17

Question about network programming on windows

I've created an IP address with the 'route' command and pointed it to my machines network ip as its gateway. (in this case, I wrote a simple program to bind a socket to this new address for listening however, i get a response saying something like 'unable to bind to address', i know the program is fine because it binds alright to my loopback address.

Is there something I need to do be able to bind sockets to a newly created address with route?

Question by:dotnetisfun
    LVL 25

    Accepted Solution

    Usually, when you get an error message such as:

       'unable to bind to address'

    it means that either the IP address doesn't exist (or you can't gain access to it, perhaps due to a firewall), or another application is already listenning on that port (or something similar)..?

    Double check.
    LVL 6

    Assisted Solution

    you mean "created an IP address" is not really what it means....
    route command is only a route table operation, it not really create a IP Address, that's why you can't bind on that ip.
    here is the real way to create a additional ip address :
    in startmenu->settings->Network connection->you local connection, enter to  property form,
    select TCP/ip protocol, and click property button, and go into  "advance options",
    then  Add a IP address by click "add" button on frame "IP Address".
    LVL 5

    Assisted Solution

    by:Ali Fakoor
    I agree with Rafaelkl , he is right, Also I suggest when assigning a new IP address and manipulating the routing-table, before testing your program try to find if a real route exists between your mahine and the destination host with the 'tracert' or 'pathping' utilities.

     example of TRACEROUTE

    Tracing route to [
    over a maximum of 30 hops:

      1    <1 ms    <1 ms    <1 ms
      2    <1 ms    <1 ms    <1 ms
      3    <1 ms    <1 ms    <1 ms

    Trace complete.


    example of PATHPING

    Tracing route to [
    over a maximum of 30 hops:
      0  myhost.ecrcsp []
      3 []

    Computing statistics for 75 seconds...
                Source to Here   This Node/Link
    Hop  RTT    Lost/Sent = Pct  Lost/Sent = Pct  Address
      0                                           myhost.ecrcsp []
                                    0/ 100 =  0%   |
      1    0ms     0/ 100 =  0%     0/ 100 =  0%
                                    0/ 100 =  0%   |
      2  ---     100/ 100 =100%   100/ 100 =100%
                                    0/ 100 =  0%   |
      3    0ms     0/ 100 =  0%     0/ 100 =  0%  _gc._tcp.default-first-site-name._ []

    Trace complete.


    whish that helps,

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Suggested Solutions

    RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    759 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

    11 Experts available now in Live!

    Get 1:1 Help Now