mule入门 xmpp tcp 配置 之Client测试类

package client;

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

import sun.misc.BASE64Encoder;

public class ClientApp
{
public static void main(String args[]) throws UnknownHostException, IOException
{
   
    //创建通讯并且和主机Rock连接
    Socket cSocket=new Socket("192.168.1.20",5200);
    //打开这个Socket的输入/输出流
    OutputStream os=cSocket.getOutputStream();
    BufferedReader br = new BufferedReader(new InputStreamReader(cSocket.getInputStream()));
    String xmlStringMessage = "<qflag.xmpp.packet.IQ id='xxx' from = 'xxx'><name>wanglei</name><password>123</password></qflag.xmpp.packet.IQ>" ;
    //String xmlStringMessage = "<qflag.xmpp.packet.Message id='yyy' from = 'yyy'><body>hahaha</body></qflag.xmpp.packet.Message>" ;
    //xmlStringMessage = "ss" ;
    //BASE64Encoder bencode = new BASE64Encoder() ;
    //xmlStringMessage = bencode.encode(xmlStringMessage.getBytes()) ;
   
    os.write(xmlStringMessage.getBytes()) ;
    //os.write(xmlString.getBytes()) ;
    String msg = null;
    System.out.println("start...") ;
    try
    {
        while ((msg = br.readLine()) != null)
            System.out.println("msg = " + msg);
    }
   
   
    catch (IOException e) {                   
        e.printStackTrace() ;
    }

}
}

你可能感兴趣的:(java,.net,socket,OS,sun)