Re: multiple tcp server and client execution with close problem
- From: "Ray" <alienatsf@xxxxxxxxx>
- Date: 17 Mar 2007 18:54:44 -0700
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
.
- Follow-Ups:
- Re: multiple tcp server and client execution with close problem
- From: Barry Margolin
- Re: multiple tcp server and client execution with close problem
- References:
- multiple tcp server and client execution with close problem
- From: Ray
- Re: multiple tcp server and client execution with close problem
- From: Barry Margolin
- multiple tcp server and client execution with close problem
- Prev by Date: Re: multiple tcp server and client execution with close problem
- Next by Date: why there is no sound for the demo prgrame of alsa lib
- Previous by thread: Re: multiple tcp server and client execution with close problem
- Next by thread: Re: multiple tcp server and client execution with close problem
- Index(es):
Relevant Pages
|