static void Main(string[] args) { //(new SimpleClient()).Start(); //host = "localhost"; //host = "211.1.1.1"; //host = "::1"; string host = Energy.Base.Text.GetElementOrEmpty(args, 0); int port = Energy.Base.Cast.StringToInteger(Energy.Base.Text.GetElementOrEmpty(args, 1)); if (string.IsNullOrEmpty(host)) { host = "127.0.0.1"; } if (port == 0) { port = 9000; } string value; int integer; value = Energy.Core.Tilde.Ask("Host", host); if (!string.IsNullOrEmpty(value)) { host = value; } value = Energy.Core.Tilde.Ask("Port", port.ToString()); if (0 < (integer = Energy.Base.Cast.StringToInteger(value))) { port = integer; } string address = Energy.Core.Network.GetHostAddress(host, AddressFamily.InterNetwork); Energy.Core.Tilde.WriteLine($"Trying to connect to ~w~{address}~0~:~y~{port}~0~ and start conversation..."); IPAddress ipAddress = IPAddress.Parse(address); //IPEndPoint remoteEP = new IPEndPoint(ipAddress, port); Energy.Core.Network.SocketClient socketConnection = new Energy.Core.Network.SocketClient(); socketConnection.Host = host; socketConnection.Port = port; socketConnection.OnConnect += SocketConnection_OnConnect; socketConnection.OnReceive += SocketConnection_OnReceive; socketConnection.OnSend += SocketConnection_OnSend; socketConnection.Connect(); Energy.Core.Tilde.Pause(); }
static void Main(string[] args) { Energy.Core.Tilde.WriteLine("Welcome to ~lm~Network ~lc~Client~0~ using ~y~Energy.Core.Network.~lc~SocketClient"); Energy.Core.Network.SocketClient connection = new Energy.Core.Network.SocketClient(); connection.Host = "localhost"; connection.Port = 9000; connection.OnReceive += Connection_OnReceive; connection.OnSend += Connection_OnSend; connection.OnConnect += Connection_OnConnect; connection.OnException += Connection_OnException; connection.Timeout = 5000; connection.Retry = 1; connection.Connect(); Energy.Core.Tilde.Pause(); }