>- see footer for list info -<
Have spent a day trying to get this to work, but the Buffered Reader is
never ready and always gives "read timed out".....
Any help most appreciated.....
<cffunction name="SocketIO" returntype="string" access="public"
output="true">
<cfargument name="address" type="string" required="true">
<cfargument name="port" type="numeric" required="true">
<cfargument name="write_lines" type="string" required="true">
<cfargument name="read_lines" type="numeric" required="false"
default="1">
<cfscript>
/** create all the java objects needed to talk sockets
**/
socket = createObject("java","java.net.Socket");
inStr =
createObject("java","java.io.InputStreamReader");
input = createObject("java","java.io.BufferedReader");
output = createObject("java","java.io.PrintStream");
/** initialize our socket connection to the requested
host **/
socket.init("#arguments.address#",arguments.port);
socket.setSoTimeout(5000);
/** initialize our input/output streams for reading
and writing to the
socket **/
inStr.init(socket.getInputStream());
input.init(instr);
output.init(socket.getOutputStream(),true);
writeoutput("Socket
Connected:"&socket.isConnected()&"<br>");
//objcommon.script.doflush();
writeoutput("Before Write, Output Has
Error:"&output.checkError()&"<br>");
//objcommon.script.doflush();
/** send all the requested lines to the print stream **/
output.print("#arguments.write_lines#");
writeoutput("After Write, Output Has
Error:"&output.checkError()&"<br>");
//objcommon.script.doflush();
writeoutput("Input Ready:"&input.ready()&"<br>");
//objcommon.script.doflush();
/** read all the requested lines from the input stream
**/
response = input.readLine();
/** close all our open streams/buffers/sockets **/
try{
input.close();
output.close();
inStr.close();
socket.close();
}catch(Any err){
//don't do anything, if we got this far, we
still want to return our
response
}
return response;
</cfscript>
</cffunction>
_______________________________________________
For details on ALL mailing lists and for joining or leaving lists, go to
http://list.cfdeveloper.co.uk/mailman/listinfo
--
CFDeveloper Sponsors:-
>- Hosting provided by www.cfmxhosting.co.uk -<
>- Forum provided by www.fusetalk.com -<
>- DHTML Menus provided by www.APYCOM.com -<
>- Lists hosted by www.Gradwell.com -<
>- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<