lkml.org 
[lkml]   [1999]   [Aug]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: connect() occasionally succeeds improperly to localhost port 1024-4999
    "David S. Miller" wrote:

    > Date: Mon, 30 Aug 1999 04:00:59 +0000
    > From: Steve Underwood <steveu@netpage.com.hk>
    >
    > Eh? Sure you can listen on port X, call to port X, and succeed. Why
    > does it succeed when there is apparently nobody listening on port
    > X?
    >
    > Because at the moment you begin a connect() that
    > "source_address/source_port/destination_address/destination_port"
    > unique entity exists and is in SYN_SENT state and thus can be
    > connected to. Check the RFC's and various BSD implementation, they
    > allow it too. Better yet see Steven's TCP Illustrated Volume 2, page
    > 956 "Handle simultaneous open or self-connect".
    >
    > I see about 1 or 2 people every few months who think this is illegal,
    > it's not.

    Ah, I see the problem now. I have never properly analysed this condition
    before, as many TCP stacks have real connect problems (e.g. if you keep
    trying to connect to a non-existent machine the connection sometimes
    completes and enters the closed state, as shown on a netstat listing) so
    this problem has been lost in the noise.

    Is the only way to avoid this problem to check the randomly allocated
    port number to see if it matches the target port, or is there a more
    structured way?

    Steve



    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.rutgers.edu
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 13:53    [W:0.023 / U:89.556 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site