static void Main(string[] args) { LahoreSocketClient client = new LahoreSocketClient(); string strIPAddress = MyServer.ipAddr; string strPortInput = MyServer.mPort.ToString(); if (!client.SetServerIPAddress(strIPAddress)) { Console.WriteLine(strIPAddress, "is the wrong IP Address"); } else if (!client.SetPortNumber(strPortInput)) { Console.WriteLine(strPortInput, "is the wrong port number"); } else { client.ConnectToServer(); string strInputUser = null; do { strInputUser = Console.ReadLine(); if (!(strInputUser.Trim().Equals("<EXIT>"))) { client.SendToServer(strInputUser); } else { client.CloseAndDisconnect(); } }while (!(strInputUser.Trim().Equals("<EXIT>"))); } }
public void Socket_Handler(object sender, EventArgs e) { client = new LahoreSocketClient(); client.RaiseTextReceivedEvent += HandleTextReceived; client.RaiseServerDisconnected += HandleServerDisconnected; client.RaiseServerConnected += HandleServerConnected; string strIPAddress = ipAddress.Text; string strPortInput = "23000"; if (!client.SetServerIPAddress(strIPAddress) || !client.SetPortNumber(strPortInput)) { /* MessageBox.Show( * string.Format( * "Wrong IP Address or port number supplied - {0} - {1} - Press a key to exit", * strIPAddress, * strPortInput)); * * return;*/ } client.ConnectToServer(); Navigation.PopModalAsync(); }
//Some very good shit added private void connectClient() { client = new LahoreSocketClient(); client.RaiseSocketDataTransferEvent += HandleSocketDataTansfer; string strIPAddress = "127.0.0.1"; string strPortNumber = "23000"; if (!client.SetServerIPAddress(strIPAddress) || !client.SetPortNumber(strPortNumber)) { Console.WriteLine(string.Format("Wrong IP address or port supplied - {0} - {1} - Press a key to exit", strIPAddress, strPortNumber)); Console.ReadKey(); return; } client.ConnectToServer(); string strInputUser = null; /*do * { * strInputUser = Console.ReadLine(); * if (strInputUser.Trim() != "<EXIT>") * { * client.SendToServer(strInputUser); * } * else * { * client.CloseAndDisconnect(); * } * * } while (strInputUser != "<EXIT>");*/ }
static void Main(string[] args) { LahoreSocketClient client = new LahoreSocketClient(); client.RaiseTextReceivedEvent += HandleTextReceived; client.RaiseServerDisconnected += HandleServerDisconnected; client.RaiseServerConnected += HandleServerConnected; Console.WriteLine("*** Welcome to Socket Client Starter Example by Naeem Akram Malik ***"); Console.WriteLine("Please Type a Valid Server IP Address or hostname formatted as <HOST> and Press Enter: "); string strIPAddress = Console.ReadLine(); Console.WriteLine("Please Supply a Valid Port Number 0 - 65535 and Press Enter: "); string strPortInput = Console.ReadLine(); if (strIPAddress.StartsWith("<HOST>")) { strIPAddress = strIPAddress.Replace("<HOST>", string.Empty); strIPAddress = Convert.ToString(LahoreSocketClient.ResolveHostNameToIPAddress(strIPAddress)); } if (string.IsNullOrEmpty(strIPAddress)) { Console.WriteLine("No IP Address Supplied..."); Environment.Exit(0); } if (!client.SetServerIPAddress(strIPAddress) || !client.SetPortNumber(strPortInput)) { Console.WriteLine( string.Format( "Wrong IP Address or port number supplied - {0} - {1} - Press a key to exit", strIPAddress, strPortInput)); Console.ReadKey(); return; } client.ConnectToServer(); string strInputUser = null; do { strInputUser = Console.ReadLine(); if (strInputUser.Trim() != "<EXIT>") { client.SendToServer(strInputUser); } else if (strInputUser.Equals("<EXIT>")) { client.CloseAndDisconnect(); } } while (strInputUser != "<EXIT>"); }
private void BtnConnect_ClickAsync(object sender, EventArgs e) { if (!client.SetServerIPAddress(tbServerIP.Text)) { MessageBox.Show($"Server IP is incorrect: {tbServerIP}"); return; } if (!client.SetPortNumber(tbServerPort.Text)) { MessageBox.Show($"Server port is incorrect: {tbServerPort}"); return; } client.ConnectToServer(); }
static void Main(string[] args) { LahoreSocketClient client = new LahoreSocketClient(); client.RaiseTextReceivedEvent += HandleTextReceived; client.RaiseServerDisconnected += HandleServerDisconnected; client.RaiseServerConnected += HandleServerConnected; Console.WriteLine("*** Welcome to Socket Client Starter Example by Naeem Akram Malik ***"); Console.WriteLine("Please Type a Valid Server IP Address and Press Enter: "); string strIPAddress = "89.229.95.152"; Console.WriteLine("Please Supply a Valid Port Number 0 - 65535 and Press Enter: "); string strPortInput = "16010"; if (!client.SetServerIPAddress(strIPAddress) || !client.SetPortNumber(strPortInput)) { Console.WriteLine( string.Format( "Wrong IP Address or port number supplied - {0} - {1} - Press a key to exit", strIPAddress, strPortInput)); Console.ReadKey(); return; } client.ConnectToServer(); string strInputUser = null; do { strInputUser = Console.ReadLine(); if (strInputUser.Trim() != "<EXIT>") { client.SendToServer(strInputUser); } else if (strInputUser.Equals("<EXIT>")) { client.CloseAndDisconnect(); } } while (strInputUser != "<EXIT>"); }
static void Main(string[] args) { LahoreSocketClient client = new LahoreSocketClient(); client.RaiseTextreceivedEvent += HandleTextReceived; Console.WriteLine("Welcome to socket Client Starter Eample :D"); Console.WriteLine("Please type a valid server IP Address and press enter"); string strIPAddress = "89.228.240.20";//Console.ReadLine(); Console.WriteLine("Please Supply a Valid port Number 0 - 65335 and press Enter: "); string strPortInput = "16010";//Console.ReadLine(); if (!client.SetServerIPAdress(strIPAddress) || !client.SetPortNumber(strPortInput)) { Console.WriteLine("Wront IP Address or port nymber suppliet - {0} - {1} - Press a ke y to exit", strIPAddress, strPortInput); Console.ReadKey(); return; } client.ConnectToServer(); string strInputUser = null; do { strInputUser = Console.ReadLine(); if (strInputUser.Trim() != "<EXIT>") { client.SendToServer(strInputUser); } else if (strInputUser.Equals("<EXIT>")) { client.CloseAndDisconnect(); } } while (strInputUser != "<EXIT>"); }