GetIp

import java.io.*;
import java.net.*;
public class GetIp {
 public static void main(String args[]){
  try{
   Socket connectToServer = new Socket("127.0.0.1",8234);
   DataInputStream inFromServer = new DataInputStream(connectToServer.getInputStream());
   DataOutputStream outToServer = new DataOutputStream(connectToServer.getOutputStream());
   
   System.out.println("輸入半徑數值發送到服務器,輸入bye結束");
   String outStr,inStr;
   boolean goon = true;
   
   while(goon){
    //BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
    //outStr = buf.readLine();
    //if(outStr.equals("bye"))
     //return;
    //outToServer.writeUTF(outStr);
    try{
    Thread.sleep(1000);
    }catch(InterruptedException e){}
    outToServer.writeUTF("#1122222#11111111111111111#");
    outToServer.flush();
    //inStr = inFromServer.readUTF();
    //if(!inStr.equalsIgnoreCase("bye")){
    // System.out.println("從服務器讀到的內容是:"+inStr);
    //}
    //else
    // goon = false;
   
   }
   inFromServer.close();
   outToServer.close();
   connectToServer.close();
  }catch(IOException e){
   e.printStackTrace();
  }
  
 }

}



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章