Skip to content

Socket connect ,send and receive data, support TCP UDP, support server and client. Socket连接,支持TCP/UDP,服务端/客户端。

Notifications You must be signed in to change notification settings

MirkoWu/XSocket

Repository files navigation

Import

XSocket

//client
implementation 'com.github.mirkowu.xsocket:client:0.0.2'

//server
implementation 'com.github.mirkowu.xsocket:server:0.0.2'

Use

server

        //服务端,配置端口
        IServerManager serverManager = XSocketServer.getServer(8888,
        ServerOptions.getDefault().setSocketType(SocketType.UDP)...);
        serverManager.registerSocketListener(serverSocketListener);
        serverManager.registerClientStatusListener(clientStatusListener);
        serverManager.listen(); //启动

         //关闭
         serverManager.shutdown();

         //销毁的时候记得 移除监听
         manager.unRegisterSocketListener()
         manager.unRegisterClientStatusListener()

client

        //服务端,配置端口
        IConnectManager  manager = XSocket.config(ip, Integer.parseInt(port),
        Options.defaultOptions().setSocketType(socketType)...);
        manager.registerSocketListener(this);
        manager.connect();
        
        //断开
        manager.disconnect();
        
        //销毁的时候记得 移除监听
        manager.unRegisterSocketListener()
        //or
        manager.removeAllSocketListener();

About

Socket connect ,send and receive data, support TCP UDP, support server and client. Socket连接,支持TCP/UDP,服务端/客户端。

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages