C#字符串IP转换为TCP/IP中的ipaddress

        if (InitClass.ReadString("Jiguangji", "Port", "") != "")        {
            port = Convert.ToInt32(InitClass.ReadString("Jiguangji", "Port", ""));
        }
        try
        {
            //1,创建socket
            Socket tcpClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            //2,发起建立连接的请求
     **       IPAddress ipaddress = IPAddress.Parse(ip); //可以把一个字符串的ip地址转化成一个ipaddress的对象**
            EndPoint point = new IPEndPoint(ipaddress, port);
            tcpClient.Connect(point); //通过ip:端口号 定位一个要连接到的服务器端
                                      //发送模板给打印机`
以上是 C#字符串IP转换为TCP/IP中的ipaddress 的全部内容, 来源链接: utcz.com/z/515136.html
