public static FFAcceptor Listen(string host, SocketMsgHandler funcMsg, SocketBrokenHandler funcBroken) { string[] strList = host.Split(":"); if (strList.Length != 3) { return(null); } string ip = strList[1]; string[] ipList = ip.Split("//"); if (ipList.Length == 2) { ip = ipList[1]; } else { ip = ipList[0]; } int port = int.Parse(strList[2]); SocketCtrl ctrl = new SocketCtrl(funcMsg, funcBroken); FFAcceptor ffacceptor = new FFAcceptor(ctrl); if (ffacceptor.Listen(ip, port)) { return(ffacceptor); } return(null); }
public static IFFSocket Connect(string host, SocketMsgHandler funcMsg, SocketBrokenHandler funcBroken) { string[] strList = host.Split(":"); if (strList.Length != 3) { return(null); } string ip = strList[1]; string[] ipList = ip.Split("//"); if (ipList.Length == 2) { ip = ipList[1]; } else { ip = ipList[0]; } int port = int.Parse(strList[2]); SocketCtrl ctrl = new SocketCtrl(funcMsg, funcBroken); IFFSocket ffsocket = new FFScoketAsync(ctrl); if (ffsocket.Connect(ip, port)) { return(ffsocket); } return(null); }
public static FFAcceptor listen(string ip, int port, SocketMsgHandler funcMsg, SocketBrokenHandler funcBroken) { SocketCtrl ctrl = new SocketCtrl(funcMsg, funcBroken); FFAcceptor ffacceptor = new FFAcceptor(new SocketRecvHandler(ctrl.handleRecv), new SocketBrokenHandler(ctrl.handleBroken)); if (ffacceptor.listen(ip, port)) { return(ffacceptor); } return(null); }
public static FFSocket connect(string ip, int port, SocketMsgHandler funcMsg, SocketBrokenHandler funcBroken) { SocketCtrl ctrl = new SocketCtrl(funcMsg, funcBroken); FFSocket ffsocket = new FFScoketAsync(new SocketRecvHandler(ctrl.handleRecv), new SocketBrokenHandler(ctrl.handleBroken)); if (ffsocket.connect(ip, port)) { return(ffsocket); } return(null); }