in netmf/NetMFLite/Client.cs [744:791]
static NetworkStream Connect(string host, int port, bool useSsl)
{
var ipHostEntry = Dns.GetHostEntry(host);
Socket socket = null;
SocketException exception = null;
foreach (var ipAddress in ipHostEntry.AddressList)
{
if (ipAddress == null) continue;
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
try
{
socket.Connect(new IPEndPoint(ipAddress, port));
exception = null;
break;
}
catch (SocketException socketException)
{
exception = socketException;
socket = null;
}
}
if (exception != null)
{
throw exception;
}
NetworkStream stream;
if (useSsl)
{
SslStream sslStream = new SslStream(socket);
#if (MF_FRAMEWORK_VERSION_V4_2 || MF_FRAMEWORK_VERSION_V4_3 || MF_FRAMEWORK_VERSION_V4_4)
sslStream.AuthenticateAsClient(host, null, SslVerification.VerifyPeer, SslProtocols.TLSv1);
#elif (NANOFRAMEWORK_1_0)
sslStream.AuthenticateAsClient(host, null, SslProtocols.Tls11);
#endif
stream = sslStream;
}
else
{
stream = new NetworkStream(socket, true);
}
return stream;
}