ant-user mailing list archives

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

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

================================================================

<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"
timeoutproperty="server.not.started">

            <and>

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

            </and>

        </waitfor>

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

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

    </target>

</project>

=================================================================

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

 

test.server:

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

     [echo] server has started successfully.

 

BUILD SUCCESSFUL

Total time: 59 seconds

tcp        0      0 ::ffff:127.0.0.1:39001      ::ffff:127.0.0.1:39001
TIME_WAIT   

 

 

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 

weifeng.niu@bea.com <mailto:weifeng.niu@bea.com> 

 


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.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message