Here you can find the source of doSend(String command, String server, String port)
static void doSend(String command, String server, String port) throws IOException
//package com.java2s; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.OutputStream; import java.net.Socket; public class Main { static void doSend(String command, String server, String port) throws IOException { Socket socket = new Socket(server, Integer.parseInt(port)); OutputStream os = socket.getOutputStream(); BufferedOutputStream out = new BufferedOutputStream(os); out.write(command.getBytes());/*ww w . j av a 2s . co m*/ out.write('\r'); out.flush(); socket.close(); } }