我的server端和client端分处于不同的网段,网关是不同的,但能够ping通的
解决方案 »
- snmp 开发 急 急 急!
- eclispe的一个使用问题,请教
- 文件下载
- MyEclipse无法创建数据库表的映射文件
- hibernate中如何做修改一个大的表中的一个字段
- java基础学完了,接下来看哪些内容,请大家指点
- 告诉我下Struts中logic:iterate标记的使用,郁闷好久了
- Re:请问: 如何得到tomcat安装后的路径?
- tomcat连接池的问题,为什么我的web页面里ado连接已经关闭啦。为什么到最后会提示没有可用的连接池了呢?急!!
- iText中,如何设置纸张为纵向打印
- 为什么我的j2ee -verbose用不起来呢??(急)按最高分给了
- 请教:动态进行ejb调用的问题
做了少量的修改,最好能找书具体学下:
//: JabberClient.java
// Very simple client that just sends
// lines to the server and reads lines
// that the server sends.
import java.net.*;
import java.io.*;public class JabberClient {
public static void main(String[] args)
throws IOException {
// 修改到想要的端口号
String port = "8080"; // Passing null to getByName() produces the
// special "Local Loopback" IP address, for
// testing on one machine w/o a network:
InetAddress addr =
InetAddress.getByName(null);
// Alternatively, you can use
// the address or name:
// InetAddress addr =
// InetAddress.getByName("127.0.0.1");
// InetAddress addr =
// InetAddress.getByName("localhost");
System.out.println("addr = " + addr);
Socket socket =
new Socket(addr, port);
// Guard everything in a try-finally to make
// sure that the socket is closed:
try {
System.out.println("socket = " + socket);
BufferedReader in =
new BufferedReader(
new InputStreamReader(
socket.getInputStream()));
// Output is automatically flushed
// by PrintWriter:
PrintWriter out =
new PrintWriter(
new BufferedWriter(
new OutputStreamWriter(
socket.getOutputStream())),true);
for(int i = 0; i < 10; i ++) {
out.println("howdy " + i);
String str = in.readLine();
System.out.println(str);
}
out.println("END");
} finally {
System.out.println("closing...");
socket.close();
}
}
} ///:~注:我没有调试这个代码,直接考过来的,做简单修改的。
你用程序开2个Port在你所需要的PC上,做个测试。