Torna al Thread
Socket CreateSocket(string machineAddress, int port)
{
IPHostEntry iphostEntry = null;
iphostEntry = Dns.GetHostEntry(machineAddress);
foreach (IPAddress address in iphostEntry.AddressList)
{
IPEndPoint ipe = new IPEndPoint(address.Address, port);
Socket tempSocket = new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
tempSocket.Connect(ipe);
if (tempSocket.Connected)
{
_state = StateConnection.CONNECTED.ToString();
return tempSocket;
}
}
return null;
}