Page 637 - 3-2
P. 637

import java.io.*;
            import java.net.*;


            public class TestClient01
            {
            public static void main( String args[] ) throws IOException
            {
            BufferedReader in = new BufferedReader( new InputStreamReader( System.in ) );


            Socket sock = null; //  접속할 소켓
            DataInputStream din; // READ  스트림
            DataOutputStream dout; // WRITE   스트림


            // int recv_int; //  서버로부터 받을 변수값
            String send_str = "", recv_str = ""; //  서버에게 보낼 문자열


            try
            {
            sock = new Socket( "192.168.0.56", 60000 );
            //  소켓과 스트림결합
            din = new DataInputStream( sock.getInputStream() ); // READ STREAM,     서버에서 받아오는 신호
            //  연결
            dout = new DataOutputStream( sock.getOutputStream() ); // WRITE,    서버로 보내고자하 하는 신호
            // STREAM   연결


            System.out.println( "***************  접속성공! ***************" );


            //  서버로부터 정수형 값을 받는과정
            // recv_int = read.readInt();
            // System.out.println(" 서버왈: " + recv_int);


            while( true )
            {
            //  서버에게 문자열 값을 전달하는과정
            System.out.print( " 송신할 프로토콜: " );
            send_str = in.readLine();


            try
            {
            dout.writeUTF( send_str );      // 여기가 서버로 보내는거
            }
            catch( Exception e )
            {
                    e.printStackTrace();
            }


                                                         - 637 -
   632   633   634   635   636   637   638   639   640   641   642