multiple tcp server and client execution with close problem - Unix

This is a discussion on multiple tcp server and client execution with close problem - Unix ; Hi, I have a tcp/ip server and client program runs like this: server side: main: loop multiple times { system("./MyServer"); } In the MyServer executable code: socket ioctl blocking bind listen while loop to accept recv something recv data send ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: multiple tcp server and client execution with close problem

  1. multiple tcp server and client execution with close problem

    Hi, I have a tcp/ip server and client program runs like this:

    server side:
    main:
    loop multiple times
    {
    system("./MyServer");
    }

    In the MyServer executable code:
    socket
    ioctl blocking
    bind
    listen
    while loop to accept
    recv something
    recv data
    send other things
    close


    Client side:
    loop multipe times
    {
    socket
    ioctl blocking
    while loop to connect
    send something
    send data
    shutdown send
    recv other things
    close
    }

    The problem it has is after first finishing first loop with successful
    operation on both server and client, server is waiting for client, and
    client is waiting to successfully connect to server again. So both are
    waiting without doing anything. This is due to the close function
    cannot complete closing the socket level descriptor for client side
    detected by perror (maybe server side as well). Is there a way to get
    around this problem? I have read the unix faq and search thru
    comp.unix.programmer, but found no better solution for my situation
    ( I tried with or without shutdown at the end, also tried
    SO_REUSEADDR, SO_LINGER with no luck).

    The server code is a stand-alone executable. It has to be spawned by
    function system for multiple times. I cannot get the server on all the
    time then. So I decided to connect to server for multiple times from
    client side. Is there a way in algorithm to better solve this
    situation?

    Thanks in advance,

    Ray


  2. Re: multiple tcp server and client execution with close problem

    Don't post the same question multiple times in different groups. If
    your question is really appropriate for both groups (this question is
    really best for just comp.unix.programmer) then cross-post, don't
    multi-post.

    --
    Barry Margolin, barmar@alum.mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    *** PLEASE don't copy me on replies, I'll read them in the group ***

+ Reply to Thread