Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPAddress address = Dns.GetHostAddresses(ip)[0]; socket.Bind(new IPEndPoint(address, port));