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 6644119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:07:48+00:00 2026-05-26T00:07:48+00:00

Hej Hej, I have a .Net program that has to run on a cluster

  • 0

Hej Hej,

I have a .Net program that has to run on a cluster of server 2008.
To find out the right IP I resolve the dns by

GetHostEntry(VarDefinedInfConfig).AddressList(0)

but when I am converting my old code (this code picks the wrong IP) dns.GetHostName().AddressList(0) => this returns a virtual IP and not the right one.

So I changed my TcpListener to (dns is parameter from config)

Dim listener As TcpListener = New TcpListener(New IPEndPoint(Net.Dns.GetHostEntry(dns).AddressList(0), 8001))
listener.Start()

In the old way a tcpclient was defined by this code

  Dim client As TcpClient = New TcpClient(Environment.MachineName, 8001)
  Console.WriteLine("Done...")
  client.Close()

This also connects to the wrong IP so I found the overload of TcpClient and used that one

New way:

 Dim client2 As TcpClient = New TcpClient(New IPEndPoint(Net.Dns.GetHostEntry(dns).AddressList(0), 8001))
    Console.WriteLine("Done")
    client2.Close()

But when I use the second one I got the exception “Only one usage of each socket address (protocol/network address / port) is normally permitted.

Weird thing is if I get the IP from the MachineName is exactly the same as the ip retreived from dns with parameter.

Does anybody know the cause of this exception? Normally they should have the same result.

Greetz,

Jonathan

  • 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-26T00:07:49+00:00Added an answer on May 26, 2026 at 12:07 am

    Is it possible that you overlooked the main difference between the 2 mentioned TcpClient constructors (MSDN)?:

    TcpClient(String, Int32) .. connects to the specified port on the specified host.

    TcpClient(IPEndPoint) .. binds it to the specified local endpoint.

    So effectively, with the first constructor a socket is opened on an available, "OS-assigned" local port and then connected to the server, whose address or DNS-name and port are passed in as arguments; after that you’re ready to send or receive data.

    With the second constructor a socket is just opened on a certain local port (which is identified in the endpoint argument), but that’s all – no connection to any [remote, or even local] server is made, because no server info is known yet; you’d need to call one of Connect(.) methods before making any comm operations (similar to the workaround you found).

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

Sidebar

Related Questions

Hej, assuming I have a code that looks like this: List<User> userList = GetUserByName
Hej All I have some code that builds a new TYPE runtime, it sets
Hej, I have some data shipped out with the app which shall be copied
Hej everyone, problem : I am looking for right way to convert an index
Hej folks, I'm currently completely stuck with the following and don't even have the
I have this code, int main() { std::string st; std::stringstream ss; ss<<hej hej med
I have a simple question, how to convert this server into multithreded as far
Hej All, I've an application that listens on a socket. The problem is that
hej Hej, My Question is related to my previous post: Get right ip adress
Well i have implemented my own NFS server and everything is working good but

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.