日期:2014-05-18 浏览次数:20703 次
Socket socket=null;
try {
//在客户端建立一个Socket对象,请求建立连接:
socket=new Socket("125.208.3.12",11084);
//输出
System.out.println("连接已建立:"+socket);
OutputStream os=socket.getOutputStream();
InputStream in=socket.getInputStream();
//发送登录
os.write(login.getBytes());
os.flush();
Thread.sleep(3000);
//发送信息01
os.write(sendmes.getBytes());
os.flush();
Thread.sleep(3000);
//发送信息02
os.write(sendmes1.getBytes());
os.flush();
int c;
while((c=in.read())!=-1)
{
System.out.print((char)c);
}
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}