private void BeginConnect() { closed = true; socket = MiscOperation.NewSocket(); try { socket.BeginConnect(address, port, EndConnect, null); } catch (Exception e) { this.HandleError(e); } }
internal static void BeginConnect(this Client client) { client.closed = true; client.socket = MiscOperation.NewSocket(); try { client.socket.BeginConnect(client.address, client.port, EndConnect, client); } catch (Exception e) { client.HandleError(e); } }
public void Start(string address, int port) { if (!isServerRunning) { isServerRunning = true; var ip = new IPAddress(address.Split('.').Select(x => Convert.ToByte(x)).ToArray()); var endpoint = new IPEndPoint(ip, port); listener = MiscOperation.NewSocket(); listener.Bind(endpoint); listener.Listen(Const.BackLogLimit); new Thread(this.BeginAccept).Start(); } }