SocketConnection hc = (SocketConnection) Connector .open("socket://79.99.7.153:80"); DataOutputStream dout = new DataOutputStream(hc.openOutputStream()); DataInputStream din = new DataInputStream(hc.openInputStream()); String userPass = "login" + ":" + "password";
... SocketConnection client = (SocketConnection) Connector.open("socket://" + hostname + ":" + port); // set application-specific options on the socket. Call setSocketOption to set other options client.setSocketOption(DELAY, 0); client.setSocketOption(KEEPALIVE, 0); InputStream is = client.openInputStream(); OutputStream os = client.openOutputStream(); // send something to server os.write("some string".getBytes()); // read server response int c = 0; while((c = is.read()) != -1) { // do something with the response } // close streams and connection is.close(); os.close(); client.close(); ...
OutputStream out = connection.openOutputStream(); InputStream in = connection.openInputStream();