title: Socket connection with coldfusion
body: <p>I'm trying to use the custom function, <a href="https://cflib.org/udf/easySocket" rel="nofollow noreferrer">easySocket</a>. It allows ColdFusion developers to connect to remote hosts through the TCP/IP protocol and transmit messages. Very useful for implementing chat rooms, integrate with third party applications such as merchant carts etc.</p>
  
  <pre><code>&lt;cffunction name="easySocket" access="private" returntype="any" hint="Uses Java Sockets to connect to a remote socket over TCP/IP" output="false"&gt;
  
      &lt;cfargument name="host" type="string" required="yes" default="localhost" hint="Host to connect to and send the message"&gt;
      &lt;cfargument name="port" type="numeric" required="Yes" default="8080" hint="Port to connect to and send the message"&gt;
      &lt;cfargument name="message" type="string" required="yes" default="" hint="The message to transmit"&gt;
  
      &lt;cfset var result = ""&gt;
      &lt;cfset var socket = createObject( "java", "java.net.Socket" )&gt;
      &lt;cfset var streamOut = ""&gt;
      &lt;cfset var output = ""&gt;
      &lt;cfset var input = ""&gt;
  
      &lt;cftry&gt;
          &lt;cfset socket.init(arguments.host,arguments.port)&gt;
          &lt;cfcatch type="Object"&gt;
              &lt;cfset result = "#cfcatch.Message#&lt;br&gt;Could not connected to host &lt;strong&gt;#arguments.host#&lt;/strong&gt;, port &lt;strong&gt;#arguments.port#&lt;/strong&gt;."&gt;
              &lt;cfreturn result&gt;
          &lt;/cfcatch&gt;
      &lt;/cftry&gt;
  
      &lt;cfif socket.isConnected()&gt;
          &lt;cfset streamOut = socket.getOutputStream()&gt;
  
          &lt;cfset output = createObject("java", "java.io.PrintWriter").init(streamOut)&gt;
          &lt;cfset streamInput = socket.getInputStream()&gt;
  
          &lt;cfset inputStreamReader= createObject( "java", "java.io.InputStreamReader").init(streamInput)&gt;
          &lt;cfset input = createObject( "java", "java.io.BufferedReader").init(InputStreamReader)&gt;
  
          &lt;cfset output.println(arguments.message)&gt;
          &lt;cfset output.println()&gt;
          &lt;cfset output.flush()&gt;
  
          &lt;cfset result=input.readLine()&gt;
          &lt;cfset socket.close()&gt;
      &lt;cfelse&gt;
          &lt;cfset result = "Could not connected to host &lt;strong&gt;#arguments.host#&lt;/strong&gt;, port &lt;strong&gt;#arguments.port#&lt;/strong&gt;."&gt;
      &lt;/cfif&gt;
  
      &lt;cfreturn result&gt;
  &lt;/cffunction&gt;
  
  &lt;cfoutput&gt;#easySocket('192.168.0.55','8080','Hello from ColdFusion')#&lt;/cfoutput&gt;
  </code></pre>
  
  <p>but this throws the error "Object Instantiation Exception"</p>