hi guys!
i am developing an application for the company i work and the problem is the
next :
i am currently developing a flash based client that acceses to a ftp server
and the extract some files from 1 directory that contains many txt, then i get
the that info into flash so i can select 1 determined text file in the ftp and
read it into flash
the problem comes when i want to know if the remote host is connected to give
them support, the remote hosts are stores that get connected by dialing a
number to connect to the internet, so making ping is a vital part of the
application being created
is there a way or a tag to do this, i have right now coldfusion 6.1 developer
edition
thx for any help!
JonathanBigelow - 28 Apr 2005 17:13 GMT
You could probably do something like this:
<cftry>
<cfexecute name="ping.exe" arguments="ftp.whatever.com"
timeout="5"></cfexecute>
<cfcatch type="Any">
Ping failed
</cfcatch>
</cftry>
AcidGuy - 28 Apr 2005 19:06 GMT
this worked perfectly but the informartion returned is poor or none at the end
of the 5 seconds transaction,
just return something when the operation has failed and a null when the
operation or the ping has been estabilished, is there a way to get more details
?
thx in advanced !
PaulH - 28 Apr 2005 19:24 GMT
if it doesn't need to be ping, you might look at java sockets (i'm at home,
i'll see if i can post better code when i get to the office tomorrow). this is
from memory:
<cfscript>
try {
socket=CreateObject("java", "java.net.Socket");
hostIP=javacast("string", "10.10.10.10"); // your remote host goes here
dayTimePort=javacast("int", 13);
socket.init(hostIP, dayTimePort);
socket.setSoTimeout(100);
ServerIP = socket.toString();
ServerPort = socket.getPort();
socket.close()
} // try
catch ("java.net.SocketException",e) {
socket.close();
}
</cfscript>
JonathanBigelow - 28 Apr 2005 19:29 GMT
What version of CF are you using? On 6.1 I get the following output with just
that code:
Pinging www.yahoo.akadns.net [66.94.230.34] with 32 bytes of data:
Reply from 66.94.230.34: bytes=32 time=31ms TTL=51
Reply from 66.94.230.34: bytes=32 time=235ms TTL=51
Reply from 66.94.230.34: bytes=32 time=313ms TTL=51
Reply from 66.94.230.34: bytes=32 time=31ms TTL=51
Ping statistics for 66.94.230.34: Packets: Sent = 4, Received = 4, Lost = 0
(0% loss), Approximate round trip times in milli-seconds: Minimum = 31ms,
Maximum = 313ms, Average = 152ms
You should be able to parse through that pretty easily to clean up the results
if you like...
JonathanBigelow - 28 Apr 2005 19:32 GMT
Also you can speed it up a bit by using
<cfexecute arguments="www.yahoo.com -n 1"....></cfexecute>
which will only send 1 echo request.
AcidGuy - 28 Apr 2005 19:55 GMT
maybe the problem is in the server trying to send the vars to flash, what i see
is a big line of space ... , i will make function all those codes trying from
diferent ways tomorrow, now i have to go to university
thx for your support !
PaulH - 29 Apr 2005 03:37 GMT
just to keep my promise:
<cfscript>
try {
socket=CreateObject("java", "java.net.Socket");
readerObj=createObject("java","java.io.InputStreamReader");
bufferedObj=createObject("java","java.io.BufferedReader");
hostIP=javacast("string", "10.10.10.10"); // your remote host goes here
dayTimePort=javacast("int", 13); // or some other port that is allowed on
their firewall/host
socket.init(hostIP, dayTimePort);
socket.setSoTimeout(1000); // some reasonable timeout value
inReader=readerObj.init(socket.getInputStream());
bReader=bufferedObj.init(inReader);
isAlive=true;
// check that box
tStamp=bReader.readLine();
ServerIP = socket.toString();
ServerPort = socket.getPort();
socket.close();
if (isAlive)
writeoutput("server #serverIP# (#serverPort#) is alive at #tStamp#");
} // try
catch ("java.net.SocketException" e) {
socket.close();
isAlive=false;
writeoutput("server #hostIP# (#dayTimePort#) is dead as a doorknob at
#now()#");
}
</cfscript>
AcidGuy - 29 Apr 2005 17:04 GMT
i think there is something missing in the code,
it gives me the next error with flash Remoting :
--------------------------------------------------------------------------------
---------------------
Service threw an exception during method invocation: Object Instantiation
Exception.
--------------------------------------------------------------------------------
---------------------
And with Coldfusion :
--------------------------------------------------------------------------------
---------------------
Object Instantiation Exception
--------------------------------------------------------------------------------
---------------------
PaulH - 29 Apr 2005 20:52 GMT