Writing data |
After establishing a connection you may write data to the server by getting the java.io.OutputStream associated with the connection. To get the output stream invoke the IpClient#getOutputStream method.
Example
// create new IpClient instance IpClient client = new IpClient("www.yahoo.com",80);
// establish connection client.connect();
// get output stream OutputStream out = client.getOutputStream();
// send data String command = "GET / HTTP/1.0\r\n\r\n"; out.write(command.getBytes()); out.flush();
// get input stream InputStream in = client.getInputStream();
// read data from server int i = 0; while((i = in.read()) != -1) { System.out.print((char)i); } |