Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:Good Example. Plz, give me one point [Re:floater]
jam





发贴: 79
积分: 30
于 2003-04-14 10:03 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
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.
}
}
}




关于 异常 。。。。 谢谢指教

话题树型展开
人气 标题 作者 字数 发贴时间
8045 Good Example. Plz, give me one point jam 907 2003-04-09 19:29
7233 Re:Good Example. Plz, give me one point why 30 2003-04-10 22:19
7102 Re:Good Example. Plz, give me one point floater 128 2003-04-11 00:43
7271 Re:Good Example. Plz, give me one point jam 920 2003-04-11 09:35
7213 Re:Good Example. Plz, give me one point jam 381 2003-04-14 15:09
7322 Re:Good Example. Plz, give me one point jam 373 2003-04-15 13:54
7047 Re:Good Example. Plz, give me one point floater 68 2003-04-11 14:20
7245 Re:Good Example. Plz, give me one point jam 678 2003-04-11 16:07
6843 Re:Good Example. Plz, give me one point jiangns3000 12 2003-04-11 15:02
6968 Re:Good Example. Plz, give me one point jiangns3000 259 2003-04-11 20:46
6835 Re:Good Example. Plz, give me one point jiangns3000 55 2003-04-11 20:50
6893 Re:Good Example. Plz, give me one point jiangns3000 131 2003-04-11 22:33
6912 Re:Good Example. Plz, give me one point jiangns3000 141 2003-04-11 23:10
6999 Re:Good Example. Plz, give me one point floater 49 2003-04-12 07:27
7284 Re:Good Example. Plz, give me one point jam 1699 2003-04-14 10:03
7156 Re:Good Example. Plz, give me one point jam 262 2003-04-14 10:12

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   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