Re: read on socket shows EOF... but only when app is running in background
From: Nils Weller (me_at_privacy.net)
Date: 08/19/04
- Next message: Nils R. Weller: "Re: read on socket shows EOF... but only when app is running in background"
- Previous message: Jens.Toerring_at_physik.fu-berlin.de: "Re: flex/bison vs switch"
- In reply to: Ruud Schramp: "read on socket shows EOF... but only when app is running in background"
- Next in thread: Ruud Schramp: "Re: read on socket shows EOF... but only when app is running in background"
- Reply: Ruud Schramp: "Re: read on socket shows EOF... but only when app is running in background"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 19 Aug 2004 15:07:03 GMT
In article <41244972$1@aurora.telecom.tno.nl>, Ruud Schramp wrote:
> Does anybody know other reasons a TCP Socket will read eof besides being
> closed localy or receiving a FIN packet?
No.
> My multi threaded server application doesn't work when run in the
> background.
The fact that you call fork() in a multithreaded application may be your
first problem already. Do you create your threads before calling fork()
or afterwards, and does the parent process perform any other actions
related to multithreading before it exits (such as acquiring mutexes)?
> The application is intended to run as a daemon so I want to create a
> commandline option that puts it in the background. It does work when
> run in the foreground, even when started with a "&" option, but not
> when an internal fork is used.
I recommend that you call the setsid() function after performing the
fork(). Also, the parent should exit by calling _exit(), not exit() (a
return from main() will call exit().)
But from the information you have supplied, it's hard to guess what's
wrong. This certainly does not seem like a common programming problem
to me, or at least it's not one I have experienced myself. What else
have you tried on the server side? Is the server structured in such a
way that you can constantly monitor the socket for its validity?
-- My real email address is ``nils<at>sipoc<dot>de''
- Next message: Nils R. Weller: "Re: read on socket shows EOF... but only when app is running in background"
- Previous message: Jens.Toerring_at_physik.fu-berlin.de: "Re: flex/bison vs switch"
- In reply to: Ruud Schramp: "read on socket shows EOF... but only when app is running in background"
- Next in thread: Ruud Schramp: "Re: read on socket shows EOF... but only when app is running in background"
- Reply: Ruud Schramp: "Re: read on socket shows EOF... but only when app is running in background"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|