2
回答
基于TCP协议的socket传输,java实现, 外国教授的要求我不太清楚
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   

是不是这个意思,文本文档里存储了主机和端口号,从文本文档随机读取一行目的主机和端口,然后建立连接,发送5个随机整数(+或-),之后关闭连接,10个进程,每个进程都重复这样的步骤5000次。
我的问题是,随机读取端口号建立链接这步怎么实现,网上的教学都是指定好了固定的IP和端口(例如Socket s = new Socket("100.65.27.22", 10005);)。
PS JAVA初学,以前学过C和C++
原文:
In this assignment, you will be creating a set of processes P that are launched on different machines. At each process, you will read information about this set of processes from a text file: each line in the file will contain the host and port information for the process comprising this set. A process should never attempt to connect to itself; so it should not appear its list of available processes. It follows that the config file at each process will be different.
Each process participates in a set of rounds. Each round involves a process connecting to a randomly chosen process in the set of processes P. All communications in the system will be based on TCP. Once a connection is established to a random node, the initiating process sends 5 messages to the targeted process. The payload of each message is a random integer (positive or negative). At the end of each round the socket connection is closed and the process is repeated by choosing another node at random from the set P. Each process will initiate 5000 such rounds.
译文:
在此作业中,您将创建一组在不同机器上启动的进程P。在每个进程中,您将从文本文件中读取有关此组进程的信息:文件中的每一行将包含包含此集合的进程的主机和端口信息。进程不应该尝试连接到自己;所以它不应该出现其可用进程的列表。因此,每个进程的配置文件将不同。
每个进程都参与几轮。每一轮涉及到一组进程连接到随机选择的进程。系统中的所有通信将基于TCP。一旦连接建立到随机节点,启动过程就会向目标进程发送5条消息。每个消息的有效负载是一个随机整数(正或负)。在每一轮结束时,套接字连接被关闭,并且通过从集合P中随机选择另一个节点来重复该过程。每个过程将发起5000个这样的回合。

举报
whtjane
发帖于3个月前 2回/125阅
顶部