Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!weretis.net!feeder1.news.weretis.net!newsfeed.CARNet.hr!garrison.bnet.hr!gregory.BNet.hr!not-for-mail From: Josip Almasi Newsgroups: comp.lang.java.programmer Subject: Re: java unix domain sockets ... or substitute Date: Fri, 05 Sep 2014 10:20:58 +0200 Organization: B.net Hrvatska d.o.o. Lines: 41 Message-ID: References: NNTP-Posting-Host: 109.60.125.237 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: gregory.bnet.hr 1409905258 13363 109.60.125.237 (5 Sep 2014 08:20:58 GMT) X-Complaints-To: abuse@globalnet.hr NNTP-Posting-Date: Fri, 5 Sep 2014 08:20:58 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:29917 On 09/04/2014 11:14 AM, Andreas Leitgeb wrote: > Josip Almasi wrote: >> IMHO domain sockets are not in java for good reason - they add little >> value over pipes when used locally, but add complexity, as it's easier >> to work with files/pipes than sockets. > > Exactly that added complexity is what I now have to mimic with pipes and > where it ends up even more complicated than what I'd think domain sockets > would have been. > As a bonus, I'd be able to detect stale sockets, in case the server crashed, > but I cannot reliably detect a stale named pipe. Accessing it will merely > block until someone else restarts the server. I think you can detect stale pipes, with fuser and/or lsof - they will not be opened by any processes. Something like for FILE in `find /tmp -type p` do PROCCNT=`fuser $FILE | wc -w` if (( $PROCCNT == 1 )) fuser -k $FILE elif (( $PROCCNT == 0 )) then rm -f $FILE fi done every (couple of) minute(s). >> With domain sockets you'd also get filesystem nodes, just not two for >> each client, with less bookkeeping of stale nodes. >> Then again, you also can create pipes in /tmp, and leave cleanup to system. > > The mean-time between reboots is rather long (think of years), so I couldn't > just idly fill /tmp. The rate of client-connects is expected to be high > enough that this would cause problems. Cleaning /tmp is usually night-time cron job. Think you only need one or two cron jobs to keep your pipes under control. I haven't seen AIX, Solaris nor ksh in years though. Regards...