socket connection to nowhere?! - TCP-IP

This is a discussion on socket connection to nowhere?! - TCP-IP ; I have 3 Linux bones, 1 server and 2 clients - one client active at any one time, as software dies on one client, watchdog software starts the other client. At the server, there are actually 2 relevant processes running, ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: socket connection to nowhere?!

  1. socket connection to nowhere?!

    I have 3 Linux bones, 1 server and 2 clients - one client active at
    any one time, as software dies on one client, watchdog software starts
    the other client.
    At the server, there are actually 2 relevant processes running, the
    client opens a socket connection to each.

    As client1 software is stopped, both server processes notice the
    disconnection.
    client2 then starts up, and issues connection request to each server
    process in turn.
    The first server process notices the incoming connection, accepts it
    and all is fine.
    The second server process never notices the incoming connection -
    however client2 thinks that both connections are OK!!
    Looking in netstat on client2 shows both connections ESTABLISHED;
    looking in netstat -p at the server shows the connections ESTABLISHED,
    but the second connection has no process listed (just a dash).

    Any ideas what might be happening, or best way to investigate?
    TIA
    M

  2. Re: socket connection to nowhere?!

    mark.bergman@thales-is.com schrieb:

    > Looking in netstat on client2 shows both connections ESTABLISHED;
    > looking in netstat -p at the server shows the connections ESTABLISHED,
    > but the second connection has no process listed (just a dash).
    >
    > Any ideas what might be happening, or best way to investigate?


    Could it be that your client process just dies instantaniously after
    establishing the connection (SIGSEGV comes to mind) and the connection
    is still "hanging" in the kernel before timing out? This should happen
    IIRC after 12 minutes - but I might be horribly mistaken here and
    confusing it with something else.

    Regards,
    Johannes

  3. Re: socket connection to nowhere?!

    On 8 Sep, 12:03, Johannes Bauer wrote:
    > I wrote:
    >
    > > Looking in netstat on client2 shows both connections ESTABLISHED;
    > > looking in netstat -p at the server shows the connections ESTABLISHED,
    > > but the second connection has no process listed (just a dash).

    >
    > Could it be that your client process just dies instantaniously after
    > establishing the connection (SIGSEGV comes to mind) and the connection
    > is still "hanging" in the kernel before timing out?


    No processes are dying.
    Client thinks it has successfully connected to 2 processes.
    Process 1 on server receives incoming connection request.
    Process 2 on server does not receive request.
    It looks like something else on the server is picking up the
    connection

    M


  4. Re: socket connection to nowhere?!

    On 8 Sep, 11:51, I wrote:
    > The second server process never notices the incoming connection -
    > however client2 thinks that both connections are OK!!
    > Looking in netstat on client2 shows both connections ESTABLISHED;
    > looking in netstat -p at the server shows the connections ESTABLISHED,
    > but the second connection has no process listed (just a dash).


    I should say that this is only intermittent.
    Sometimes it works OK, i.e. Process 2 at the server notices the
    connection request, and netstat shows all connections correct

    M

  5. Re: socket connection to nowhere?!

    mark.bergman@thales-is.com schrieb:

    > No processes are dying.
    > Client thinks it has successfully connected to 2 processes.
    > Process 1 on server receives incoming connection request.
    > Process 2 on server does not receive request.
    > It looks like something else on the server is picking up the
    > connection


    Have you done proper error checking? Do the socket() and connect() calls
    of the client *really* succeeed? Do the socket(), bind(), listen(),
    accept() calls of the server *really* succeed? If bind() succeeds in
    process 2, then it should be impossible any other process picks up the
    connection (because only one server can bind to a address/port tuple at
    a time).

    Regards,
    Johannes

  6. Re: socket connection to nowhere?!

    mark.bergman@thales-is.com writes:
    > I have 3 Linux bones, 1 server and 2 clients - one client active at
    > any one time, as software dies on one client, watchdog software starts
    > the other client.
    > At the server, there are actually 2 relevant processes running, the
    > client opens a socket connection to each.
    >
    > As client1 software is stopped, both server processes notice the
    > disconnection.
    > client2 then starts up, and issues connection request to each server
    > process in turn.
    > The first server process notices the incoming connection, accepts it
    > and all is fine.
    > The second server process never notices the incoming connection -
    > however client2 thinks that both connections are OK!!
    > Looking in netstat on client2 shows both connections ESTABLISHED;
    > looking in netstat -p at the server shows the connections ESTABLISHED,
    > but the second connection has no process listed (just a dash).


    There are two causes (I know of) for the dash:

    - user executing netstat -p doesn't have the necessary
    privileges to determine this information for a particular
    socket

    - the kernel has completed the three-way-handshake to
    establish a new connection, but the procces supposed to
    'serve' the socket hasn't yet accepted it

    The latter has been determined by running the program quoted below
    (and netcat to actually connect to the socket). Could it be that your
    server stops calling accept for some (to be determined) reason for an
    'extended' period of time?

    Connection test program:

    #include
    #include
    #include
    #include
    #include
    #include

    void dummy(int unused)
    {
    (void)unused;
    }

    int main(void)
    {
    struct sockaddr_in sin;
    int fd, rc;

    sin.sin_family = AF_INET;
    sin.sin_port = htons(4711);
    sin.sin_addr.s_addr = INADDR_ANY;

    fd = socket(PF_INET, SOCK_STREAM, 0);
    if (fd == -1) {
    perror("socket");
    exit(1);
    }

    rc = bind(fd, (struct sockaddr *)&sin, sizeof(sin));
    if (rc == -1) {
    perror("bind");
    exit(1);
    }

    rc = listen(fd, 5);
    if (rc == -1) {
    perror("listen");
    exit(1);
    }

    signal(SIGUSR1, dummy);

    pause();

    rc = accept(fd, NULL, NULL);
    if (rc == -1) {
    perror("accept");
    exit(1);
    }

    pause();
    return 0;
    }

+ Reply to Thread