ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wei Feng Niu" <>
Subject <socket> returns true thought there is no listener
Date Fri, 17 Aug 2007 07:29:57 GMT

         I have a target to detect whether a port is listening, like the


<project name="test" default="test.server">

    <target name="test.server" description="Test server.">

        <echo message="trying to test server at localhost:39001..." />

        <waitfor maxwait="300" maxwaitunit="second" checkevery="5"


                <socket server="localhost" port="39001" />



        <fail message="server did not start!" if="server.not.started" />

        <echo message="server has started successfully." />




Put the codes into a build file and run it, I got the following result:

ant -f t.xml;netstat -an|grep 39001

Buildfile: t.xml



     [echo] trying to test server at localhost:39001...

     [echo] server has started successfully.



Total time: 59 seconds

tcp        0      0 ::ffff:      ::ffff:



Thoug there is no any server on 39001 started, after a while the target
will return with "server has started successfully". It is very strange.
Seems the <socket> task makes a listener on 39001 and detect it. So far
I just found the problem on RedHat Linux. And the time that <socket>
returns are different every time you run the target. Sometimes the
target works as expected and sometimes works as above.


Does anybody know what's the cause? Thanks


Best regards

Weifeng Niu
Tel: +86 10 8528 1188 ext. 1724 <> 


Notice:  This email message, together with any attachments, may contain information  of  BEA
Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,
 copyrighted  and/or legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient, and have received
this message in error, please immediately return this by email and then delete it.
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message