首页 > 其他 > 详细

GetIp

时间:2014-12-12 19:21:16      阅读:237      评论:0      收藏:0      [点我收藏+]

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

}



GetIp

原文:http://2172006.blog.51cto.com/2162006/1589419

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!