Here’s the properties and the method that connects.
protected Socket _socketConnection =
new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
private string _host = "";
private string _hostIpAddress = "";
private int _port = 0;
public void Connect()
{
// don't allow two connections
if (_socketConnection.Connected)
return;
// get the ip address from the hostname
IPHostEntry ipHostEntry = Dns.GetHostByName(_host);
_hostIpAddress = ipHostEntry.AddressList[0].ToString();
// create the socket endpoint
IPAddress ipAddress = IPAddress.Parse(_hostIpAddress);
IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, _port);
// connect
try
{
_socketConnection.Connect(ipEndPoint);
if (OnConnect != null)
OnConnect();
}
catch
{
throw;
}
}
When I run the app under Windows 7 I get the following error:
An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call.
I’ve seen messages that talk about setting a particular option on the socket, but this is an app that has been working for years and is only happening when this app is installed on Windows 7.
Is there a compatibility flag to tweak or something?
Thanks!
Perhaps on Win7 you get a IPv6 as the _hostIpAddress. Try using something like this when instantiating the socket: