Java开发网 |
注册 |
登录 |
帮助 |
搜索 |
排行榜 |
发帖统计
|
您没有登录 |
» Java开发网 » Java SE 综合讨论区
打印话题 寄给朋友 订阅主题 |
作者 | Re:Good Example. Plz, give me one point [Re:floater] |
jam
发贴: 79 积分: 30 |
于 2003-04-14 10:03
This new question is application service. I think, I cannot use socket to solve it. I need to find new API to do. All the question is about port. if port are the same, there are no problem. But the requirement is different. I still have no idea how to do. Who can help me? import java.io.*; import java.net.*; public class Server extends java.lang.Thread { public void run() { // one of the remote int port = 5555; // maybe 6666, 7777, 8888 ServerSocket serverSocket = new ServerSocket(port); while (true) { try { Socket socket = serverSocket.accept(); //socket.getInputStream(); //socket.getOutputStream(); } catch (Exception e) { System.out.println(e.toString()); } } } } import java.io.*; import java.net.*; public class Client { public void send() { // If String[] hosts = {"192.168.0.11", "192.168.0.12", "192.168.0.13", "192.168.0.14"}; int[] ports = {5555, 6666, 7777, 8888}; for (int i=0; i<hosts.length; i++) { Socket socket = new Socket(hosts[i], ports[i]); //send different data to different remote. //If the firewall just open 9911 port can send data // and open 9922 port can receive data. // but remote only open one port to send and receive // with different port. } } } 关于 异常 。。。。 谢谢指教 |
话题树型展开 |
已读帖子 新的帖子 被删除的帖子 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |