static void Run() { Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPAddress HostIp = IPAddress.Parse("127.0.0.1"); socket.Connect(HostIp, 2626); BlinkConn conn = Blink.NewConnection(socket, 1024 * 1024, "D:/", Guid.NewGuid().ToString(), 0.001f, null, null); if (conn != null) { Console.WriteLine("Test Send String..."); for (int i = 0; i <= 50; i++) { string str = "Test String:" + i; conn.Send(str); Console.WriteLine(str); Thread.Sleep(2); if (IsExit) { conn.Dispose(); socket.Shutdown(SocketShutdown.Both); socket.Dispose(); socket.Close(); return; } } } }
static void Main(string[] args) { BlinkLog.I("=========PRESS ENTER IP eg(127.0.0.1)=========="); string ip = Console.ReadLine(); IPAddress hostIp; if (!IPAddress.TryParse(ip, out hostIp)) { Console.ReadKey(); return; } try { mSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); mSocket.Connect(hostIp, 2626); mBlinkConn = Blink.NewConnection(mSocket, 1024 * 1024, "D:/", Guid.NewGuid().ToString(), 0.01f, null, null); } catch (Exception) { BlinkLog.I("LINK TO: " + hostIp + " ERROR."); Console.ReadKey(); return; } BlinkLog.I("=========PRESS ENTER 'E' TO EXIT=========="); SendWhlie(); if (mBlinkConn != null) { mBlinkConn.Dispose(); } if (mSocket != null) { mSocket.Dispose(); mSocket.Close(); } }