0

I’m trying to get two instances of my program to communicate between them. I’ve been referred to udp, and so I’m trying to run the example from here: http://msdn.microsoft.com/en-us/library/system.net.sockets.udpclient%28v=VS.100%29.aspx But I get an error: "socketexception (0x80004005): This is usually a temporary error during hostname resolution..."

how do I solve this?

I don’t know anything about this stuff. I googled for what I needed and found this here:

//This is how you do it (kudos to sipwiz)
    UdpClient udpServer = new UdpClient(localpt); //This is what the proprietary(see question) sender would do (nothing special) 

    //!!! The following 3 lines is what the poster needs...(and the definition of localpt (of course))
    UdpClient udpServer2 = new UdpClient();
    udpServer2.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
    udpServer2.Client.Bind(localpt);

Thanks

Community
  • 1
  • 1
ispiro
  • 26,556
  • 38
  • 136
  • 291
  • 2
    Can you post the minimum code to produce the issue? Are you connecting via a hostname? Is it set up? – TheCodeKing Sep 18 '11 at 20:10
  • PS: 0x80004005 is NOT a socket error. It looks like an ActiveX/COM error. Q: Are you sure your Windows version and/or .Net version matches the minimum requirements in the link you posted (e.g. XP SP3 or higher and .Net 3.5 SP1 or higher)? – paulsm4 Sep 18 '11 at 20:16
  • @TheCodeKing My code is copied and pasted from the above web page. My system is Windows 7. – ispiro Sep 18 '11 at 20:19
  • 2
    But you must have modified it, the code won't work as is, as it's pointing to a non-existant server. Maybe this is your problem? – TheCodeKing Sep 18 '11 at 20:22

2 Answers2

2

The issue is you are using the code for the sample unmodified.

This is trying to connect to AlternateHostMachineName which does not exist, and therefore throws a 0x80004005: No such host is known exception.

You need to amend the code to connect to a real server.

TheCodeKing
  • 19,064
  • 3
  • 47
  • 70
1

The reason is that you are refering to hostnames that can't be resolved and/or your network settings (esp. DNS) are are somehow wrong...

The example you refer to contains two hostnames www.contoso.com and AlternateHostMachineName - both are not resolvable since they don't exist... you need to replace them with real hostnames or IP adresses and make sure that your DNS settings are correct/working...

Yahia
  • 69,653
  • 9
  • 115
  • 144