chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] process-fork weirdness


From: Peter Busser
Subject: Re: [Chicken-users] process-fork weirdness
Date: Thu, 17 Mar 2005 09:00:45 +0100
User-agent: KMail/1.7.2

Hi!

> (process-fork client)
> (server)
> Error: can not write to socket
> 4
> "Good Bye!"
>
> and the program does not terminate. changing the last two lines to
> (process-fork server)
> (client)
> fixes the problem.

Well, if you fork a process, then it depends on the underlying OS wether the 
child or the parent runs first. It could very well be that the client runs 
first, tries to open a socket to the server, only to find out that there is 
no such socket, because the server did not have a chance to run yet. 
Therefore there is noone listening on that port. Then the server process gets 
a chance to run, opens a socket, listens to it, but never gets a connection 
from a client, because the client already exited. Therefore it waits forever. 
You can easily verify this by telnetting to the port and type whatever the 
client would send to the server.

Your second approach first starts a server and then the client. Therefore the 
client should be able to connect to an open socket. However, theoretically it 
still has a race condition, so it can still break.

Groetjes,
Peter.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]