You might want to access URL objects or TCP ports directly, not using the Connectors. The following code is an example that can be put in your Prolog:
// This example creates a TCP connection to www.example_page_only.com and asks for a bad page var tcp = new java.net.Socket ( "www.example_page_only.com", 80 ); var inp = new java.io.BufferedReader ( new java.io.InputStreamReader ( tcp.getInputStream() ) ); var out = new java.io.BufferedWriter ( new java.io.OutputStreamWriter ( tcp.getOutputStream() ) ); task.logmsg ("Connected to server"); // Ask for a bad page out.write ("GET /smucky\r\n"); out.write ("\r\n"); // When using buffered writers always call flush to make sure data is sent on connection out.flush (); task.logmsg ("Wait for response"); var response = inp.readLine (); task.logmsg ( "Server said: " + response );
// This example uses the java.net.URL object instead of the raw TCP socket object var url = new java.net.URL("http://www.example_page_only.com"); var obj = url.getContent(); var inp = new java.io.BufferedReader ( new java.io.InputStreamReader ( obj ) ); while ( ( str = inp.readLine() ) != null ) { task.logmsg ( str ); }