Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.development.apps > #483

Re: issue with tcp sockets on linux

From GH <yzghan@gmail.com>
Newsgroups comp.os.linux.development.apps
Subject Re: issue with tcp sockets on linux
Date 2012-06-04 07:01 -0700
Organization http://groups.google.com
Message-ID <0f72a1b3-a047-4517-9b52-4d2096ac725a@googlegroups.com> (permalink)
References <a1e2e61b-79fd-44c0-ae8f-c43aec0dd4ae@googlegroups.com> <87bolguxmp.fsf@sapphire.mobileactivedefense.com> <1ef15472-7d85-4890-9d65-886b85e72908@googlegroups.com> <87aa10t2ya.fsf@sapphire.mobileactivedefense.com>

Show all headers | View raw


I agree that the problem arose from fork() where the child does not close the open fds and I believe I had the solution for the problem. 

Now what's still puzzling me is as in my original post when the child does not close those fds: netstat shows on client side the connection in ESTABLISHED state while on server side netstat reports no such connection. I would expect that kernel on the server should close the socket and recv() on client should return 0. But what I saw is that client hangs on recv().

On Tuesday, May 22, 2012 3:45:17 PM UTC-4, Rainer Weikusat wrote:
> GH writes:
> > On Tuesday, May 22, 2012 9:57:18 AM UTC-4, Rainer Weikusat wrote:
> >> The usual cause of this phenomenon would be that the server started
> >> another program which is still running and inherited the established
> >> socket because FD_CLOEXEC wasn't set.
> >
> > Thank you for your reply. It is very insightful although my
> > situation is not exactly as you described. My app does not call
> > exec() or similar ones. It does conditionally call fork() where the
> > child does not close() the open fd's.
> 
> [Could you please order quoted text and new text in this way?]
> 
> Since descriptors don't change at all accross a fork, that obviously
> suffers from the same issue.
> 
> On linux, the netstat -np command could be used to determine which
> process keeps your connection open.

Back to comp.os.linux.development.apps | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

issue with tcp sockets on linux GH <yzghan@gmail.com> - 2012-05-22 06:25 -0700
  Re: issue with tcp sockets on linux Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-05-22 14:57 +0100
    Re: issue with tcp sockets on linux GH <yzghan@gmail.com> - 2012-05-22 11:24 -0700
      Re: issue with tcp sockets on linux Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-05-22 20:45 +0100
        Re: issue with tcp sockets on linux GH <yzghan@gmail.com> - 2012-06-04 07:01 -0700
          Re: issue with tcp sockets on linux "Ersek, Laszlo" <lacos@caesar.elte.hu> - 2012-06-05 00:22 +0200

csiph-web