Re: multiple tcp server and client execution with close problem



On Mar 17, 3:30 pm, Barry Margolin <bar...@xxxxxxxxxxxx> wrote:
In article <1174117981.427306.6...@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,





"Ray" <aliena...@xxxxxxxxx> wrote:
Hi, I have a tcp/ipserverand client program runs like this:

serverside:
main:
loopmultipletimes
{
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 bothserverand client,serveris waiting for client, and

Why is theserverstill waiting for the client? When the client does
shutdown(fd, SHUT_WR), theserverwill read EOF, and it should stop
trying to read from the socket.





client is waiting to successfully connect toserveragain. 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 (maybeserverside 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).

Theservercode is a stand-alone executable. It has to be spawned by
function system formultipletimes. I cannot get theserveron all the
time then. So I decided to connect toserverformultipletimes from
client side. Is there a way in algorithm to better solve this
situation?

Thanks in advance,

Ray

--
Barry Margolin, bar...@xxxxxxxxxxxx
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 ***- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -

The server is still waiting because there is another function calling
system() to execute server again after its previous use. It's like
when both the server and client finish transmission, the server turns
off power, then restart again. while the client never turns off but
doing a loop to reconnect to the server again for the next
transmission. The server behaves like this because the server app is
a given executable for other major process, like Monte Carlo process.
The tcp/ip is for updating data for that process.

Thanks in advance,

Ray

.



Relevant Pages

  • Re: Socket switch delay
    ... both at the client and at the server (and why ... would you set the send buffer size to zero on a non-overlapped ... One glaring error is your client does ... So when you use a single socket, ...
    (microsoft.public.win32.programmer.networks)
  • Re: Locking on async calls
    ... you must synchronize the entire SendMessage routine as an atomic ... operation to prevent mixed messages from being transmitted to the server. ... You are correct that read and write on the socket do not interfere with each ... If you want to handle multiple client connections from one server object ...
    (microsoft.public.dotnet.general)
  • Re: socket communication: socket doesnt connect
    ... Microsoft MVP, MCSD ... As far as your server code goes, ... accept the listening socket. ... Client client = new Client; ...
    (microsoft.public.vc.language)
  • Re: TCP server stop receiving new connections
    ... reset the event mask of your listening socket each time you ... I have a strange problem in my class library used by all our client ... server applications. ... incomming connections, but keeps current connections. ...
    (microsoft.public.win32.programmer.networks)
  • Re: Design issue with WinSock/GetQueuedCompletionStatus
    ... delegate that to a shutdown routine called after all worker threads ... The application I've created is a server accepting connections on a few ... different TCP/IP ports and then lets the client run different commands. ... a TCP/IP socket can be closed for 2 different reasons: ...
    (microsoft.public.win32.programmer.networks)