src
: the folder to maintain sourceslib
: the folder to maintain dependenciesvscode with Java Extensions on jdk11
com.rftx.auth
provided authentication interface and default TokenAuthentication method for connection creating.com.rftx.conn
control conn
handler and transfer conn
handler.com.rftx.core
RFTXServer and RFTXClient.com.rftx.exception
exception classes.com.rftx.listener
event listener interfaces that may be implement by caller.com.rftx.util
tools classescom.rftx.test
testscom.rftx.core.RFTXHost
Defines an RFTX host,The RFTXHost object is required regardless of whether the caller is a server, client or both. RFTXHost stores all control connections and transfer connections accepted by RFTXServer
or created by RFTXClient
com.rftx.core.RFTXServer
Defines an RFTX server program, which is contained in the RFTXHost
object and created by the specified method. RFTXServer is a thread that accepts connections in a blocked manner and stores the connections in the connections ArrayList of RFTXHost.com.rftx.core.RFTXClient
Defines RFTX client program, which is contained in RFTXHost
and created by the specified method; RFTXClient
contains a connect(String addr, int port)
method, which is used to connect the RFTXServer program started on the specified port of the specified address.An RFTXHost object contains an RFTXServer obj and an RFTXClient obj.
Call specific methods to initialize the two objects
RFTXHost contains three Connection ArrayLists
,stores Control Conns
、Transfer Conns
andUnknown Conns
In an rftxhost object, whether a connection is created by rftxclient or accepted by rftxserver, it will be saved to the corresponding array list.
This means that connections managed by rftxserver and rftxclient in the same rftxhost is shared.
Control Conns
After the client actively connects to the server, a control connection will be created at both hosts to send the commands of sending and receiving files.Transfer Conns
Each transfer connection corresponds to a transfer task, which is used to send and receive files, will be automatically created by the underlying program.Unknown Conns
When the server accepts a connection, it temporarily defaults to an unrecognized connection, and then the connection (initiated by the client) sends an identification code to inform the server of the identity of the connection.Usually, only one RFTXHost object needs to be created in a program.
RFTXHost host=new RFTXHost("hostName");//Create an RFTXHost named hostname
hostname
It will be used to identify each other's identity when establishing a connection with the peer. Unlike token, the host name will not be authenticated and only used as identificationinitserver(int port)
method or the initclient()
method of the RFTXHost
object to initialize the RFTXServer
object or the RFTXClient
object in the RFTXHost
objectNullPointerException
will be thrownRFTXHost
object, you can only create RFTXServer
or only RFTXClient
, or to create two objects at the same timeAssum that a host:RFTXHost
Object is defined (and this is necessary)
host.initServer(3000);//Open port 3000 on this host as the service port of RFTXServer. Please ensure that the specified port of this host can be accessed externally
host.getAuthenticator.addValidToken("tester","TestToken");//Add a valid token with the name tester and the value TestToken
host.server.start();//Call this method to start the listener thread for RFTXServer
RFTXHost
contains only oneRFTXServer
object. Repeatedly calling initserver(int port)
will override the created rftxserver
and cause unexpected exceptions, especially when the server has started listeningAssume that a host:RFTXHost
Object is defined (and this is necessary)
host.initClient();//Init the client object in the host object
host.getAuthenticator().setConnToken("TestToken");//Set the token used for client connection to "TestToken"
host.client.connect("testserver.ts",3000);//Use the client object to connect to port 3000 of the server(addr:testserver.ts)
lient
object in the host
object yet.RFTXServer
, the connection will be automatically disconnected immediately after the connection is established.host.post(String peerName,String taskToken,String localFile,String remoteFile);
peerName
provide peer's hostName to set targettaskToken
taskToken of this post tasklocalFile
local file,file to be sentremoteFile
remote file,save path and file name on peere.g.
host.post("testServer","taskToken000","product/jar/rftx.jar","receive/rftx-lib.jar")
host.get(String peerName,String taskToken,String localFile,String remoteFile);
peerName
Provide the peer's hostname to set the source hosttaskToken
taskToken of this get tasklocalFile
The storage path of the received file, located locallyremoteFile
The path and file name of the peer's filee.g.
host.get("testServer","taskToken000","product/jar/rftx.jar","receive/rftx-lib.jar")
*Note: in the two methods, the order of local file and remote file is the same. Please distinguish the source file and the target file.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。