자바 코드 TCP 연결 만 들 기

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;


public class TCPClientDemo {

    /**
     * @param args
     * @throws IOException 
     * @throws UnknownHostException 
     */
    public static void main(String[] args) throws UnknownHostException, IOException {
        // TODO Auto-generated method stub

        //1.  TCP    1)IP  ,2)    
         String ip="192.168.187.129";
         int port=554;
         Socket sck=new Socket(ip,port);

         //2、     
         String content="    JAVA     -10000";
         byte[] bstream=content.getBytes("GBK");//   ,      GBK
         OutputStream os=sck.getOutputStream();
         os.write(bstream);

         //3、  TCP  
         sck.close();
    }

}

좋은 웹페이지 즐겨찾기