Feature 1: Client request data and server response data are both Java objects, and there is no need for format conversion (such as Json and xml packet conversion work). It greatly reduces development costs and makes access between two physically separated programs or services operate like a single program.
Feature 2: Data communication is passed through floating temporary ports, and high-frequency access will not cause congestion bottlenecks on the main port 1721.
Feature 3: Supports password-free login or password verification login, and password verification rules can be defined by yourself.
Feature 4: Supports custom events, programs or services events. The default is XJava event processing mechanism, that is, memory sharing mode .
Feature 5: Floating port for data communication, automatic shutdown function for timeout.

Example of server configuration
<? xml version = " 1.0 " encoding = " UTF-8 " ?>
< config >
< import name = " xconfig " class = " java.util.ArrayList " />
< import name = " server " class = " org.hy.common.net.ServerSocket " />
<!-- 系统服务配置信息 -->
< xconfig >
< server id = " Server " >
< port >1721</ port > <!-- 服务端监听主端口 -->
< minPort >17000</ minPort > <!-- 数据通讯的浮动端口的最小值 -->
< maxPort >17999</ maxPort > <!-- 数据通讯的浮动端口的最大值 -->
< closeTimeout >60</ closeTimeout > <!-- 数据通讯的浮动端口的自动关闭超时时长(单位:秒) -->
< log >false</ log > <!-- 是否显示通讯日志 -->
<!-- 自定义服务端登陆验证接口。可选的,当没有定义验证方法时,免登陆 -->
< validate class = " org.hy.demo.ServerValidate " />
< call name = " addListener " > <!-- 添加自定义通讯事件 -->
< listener class = " org.hy.demo.ServerDemo " />
</ call >
< call name = " open " /> <!-- 打开监听主端号服务 -->
</ server >
</ xconfig >
</ config >Server-side custom events
public class ServerDemo implements ServerEventListener
{
/**
* 数据通讯的事件类型。
*
* 事件类型区分大小写
*/
public String getEventType ()
{
return "Demo" ;
}
/**
* 数据通讯事件的执行动作
*/
public CommunicationResponse communication ( CommunicationRequest i_RequestData )
{
CommunicationResponse v_ResponseData = new CommunicationResponse ();
// 获取客户端请求数据
Map < String , Object > v_DataMap = ( Map < String , Object >) i_RequestData . getData ();
System . out . println ( "-- 服务端接收到的数据为:" );
Help . print ( v_DataMap );
v_ResponseData . setData ( Help . toListKeys ( v_DataMap )); // 设置返回结果
return v_ResponseData ;
}
}Examples of client access
Map < String , Object > v_DataMap = new HashMap < String , Object >();
v_DataMap . put ( "String" , "ABCDEFG" );
v_DataMap . put ( "Integer" , 1234567890 );
v_DataMap . put ( "Date" , new Date ());
CommunicationRequest v_RequestData = new CommunicationRequest ();
CommunicationResponse v_ResponseData = null ;
List < String > v_Results = null ;
v_RequestData . setEventType ( "Demo" ); // 通讯的事件类型。如果没有设置此属性,默认为XJava事件类型
v_RequestData . setDataXID ( "2017" ); // 通讯数据的标识ID。可选的,按具体业务而定
v_RequestData . setData ( i_DataMap ); // 通讯数据。可选的,按具体业务而定。可为任何Java类型,须实现 java.io.Serializable 接口
ClientSocket v_Client = new ClientSocket ( "服务端IP" , 1721 );
v_Client . setValidate ( new ClientValidate ()); // 如果服务端启用了登陆验证,则客户端要提供用户名及密码
v_ResponseData = v_Client . send ( v_RequestData ); // 发送通讯数据
v_Results = ( List < String >) v_ResponseData . getData (); // 获取服务端的返回结果。可为任何Java类型,只须实现 java.io.Serializable 接口即可Demo project https://github.com/HY-ZhengWei/CommunicationEventDemo
Single sign-in service case https://github.com/HY-ZhengWei/XSSO
Cluster Management Case https://github.com/HY-ZhengWei/LogWeb
Quote https://github.com/HY-ZhengWei/hy.common.base class library
Quote the https://github.com/HY-ZhengWei/hy.common.file class library