Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7218495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:29:24+00:00 2026-05-28T21:29:24+00:00

I am writing a VB.NET app that connects to a legacy application using TCP.

  • 0

I am writing a VB.NET app that connects to a legacy application using TCP.

The communication is working fine and is very quick once connected, but there is always a delay (of around 2.5-3.5 seconds) when I create the new connection even though I am connecting to my local machine:

Private _client As TcpClient
Public Property PortNumber As Int32 = 3338
Public Property ServerName As String = [Local machine name]

_client = New TcpClient(ServerName, PortNumber) ' <- takes some time to execute this line

Can someone suggest any improvement to this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T21:29:25+00:00Added an answer on May 28, 2026 at 9:29 pm

    It’s probably a name resolution problem. If you’re happy that the IP address corresponding to the machine name won’t change during the lifetime of the application, you can resolve it first and store the IPAddress.

    The way that TcpClient does this is by calling Dns.GetHostAddresses(hostname) and then picking a suitable address from the list it gets back (e.g. it chooses an IPv4 address if you’re using an IPv4 socket).

    Have a look at the source for TcpClient for an example – once you’ve obtained the IP address you can continue to use TcpClient in the same way.

    A TCP connection is always going to be quite an expensive thing to create (milliseconds though, not seconds), so if you’re making really large numbers of very short-lived connections, TCP might not be the best choice. This is why protocols like NTP and DNS are generally UDP-based, and why people try to make some effort to reuse connections for HTTP.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an asp.net MVC app that drives an IPhone application. I want
I'm writing a .NET app that connects to a remote hosted SQL Server. Researching
I'm writing a Windows .NET app that needs a WYSIWYG text editor control that
I'm writing an app using asp.net-mvc deploying to iis6. I'm using forms authentication. Usually
I am writing an ASP.NET app that uses a SQL Server 2005 with SSRS
I'm writing a .net win app that loads foreign assemblies and executes third party
I'm writing a .NET 3.5 app and using URI.IsWellFormedUriString(string uriString, UriKind uriKind) to verify
I am writing an asp.net app that stored an object in cache. When the
I am writing a C# .NET app that accesses an USB device which exposes
I am being tasked with writing an asp.net web app that will use ADFS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.