Socket.D v2.5.12

Socket.D - Java 开发

</> markdown

开发,主要是对 “会话” 与 “监听器” 接口的应用组合!另外,客户端使用单连接即可:

//如果不能连接正常返回(由心跳尝试不断连接)
ClientSession session = SocketD.createClient("sd:ws://127.0.0.1:8602/?u=a&p=2")
        .open();

//如果不能连接则异常
ClientSession session = SocketD.createClient("sd:ws://127.0.0.1:8602/?u=a&p=2")
        .openOrThow();

目前 Java 的传输适配有(提醒:bio 的适配,不适合做服务端):

适配基础传输协议支持端安全备注
org.noear:socketd-transport-java-kcpsd:kcpc,s/nio
org.noear:socketd-transport-java-tcpsd:tcpc,ssslbio(86kb)
org.noear:socketd-transport-java-udpsd:udpc,s/bio(86kb)
org.noear:socketd-transport-java-websocketsd:ws, sd:wssc,ssslnio(217kb)
org.noear:socketd-transport-nettysd:tcp, sd:udpc,ssslnio(2.5mb)
org.noear:socketd-transport-smartsocketsd:tcpc,ssslaio(254kb)

项目中引入任何 “一个” 或 “多个” 传输适配包即可,例如:

  • maven
<dependency>
    <groupId>org.noear</groupId>
    <artifactId>socketd-transport-netty</artifactId>
    <version>2.5.12</version>
</dependency>
  • gradle
implementation("org.noear:socketd-transport-java-kcp:2.5.12")