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();
  }
  
 }

}



你可能感兴趣的:(socket,服务器,import,public)