Last post Mar 22, 2018 11:25 AM by sukhdeep_kambo
Mar 21, 2018 12:49 PM|sukhdeep_kambo|LINK
I am using below written code.
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
int port = 5000;
if (IPAddress.TryParse(ConfigurationManager.AppSettings["Server"], out ip))
socket.Connect(ip, port) - It takes a very long time to execute, Please assist me how can I make it fast. I need to run this logic for many of the records so application goes slow down due to this.
Mar 22, 2018 09:18 AM|Eric Du|LINK
According to your description and code, i think the code is no problem, you say connect method spend more time, could you tell us how long? 10 seconds? 20 seconds?
You could check the time use the following code:
var watch = System.Diagnostics.Stopwatch.StartNew();
// the code that you want to measure comes here
var elapsedMs = watch.ElapsedMilliseconds;
Mar 22, 2018 11:25 AM|sukhdeep_kambo|LINK
Thanks for replying Eric. I calculated the time and it tool 21 seconds to execute that pat which is very greater. For the time being there are 12 objects in loop so it takes 12*21 seconds. Do you see any way out to reduce this time.