C#SimpleTcpServer无法识别IPAddress [英] C # SimpleTcpServer Does Not Recognize IPAddress

查看:232
本文介绍了C#SimpleTcpServer无法识别IPAddress的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows窗体应用程序中使用SimpleTcpServer,当我使用IPAddress 10.10.5.27时,端口8080提供Exception System.Net.Sockets.SocketException



表格从以下声明开始:

  私人   无效    Form1_Load    object   sender  < span class ="pun"style ="margin:0px; padding:0px; border:0px; font-style:inherit; font-variant:inherit; font-weight:inherit; line-height:inherit; font-family:inherit ; vertical-align:baseline; color:#303336">,    EventArgs   e    
{
这个 隐藏 ();
这个 WindowState = FormWindowState 最小化 ;

服务器
= SimpleTcpServer
{
// server.Delimiter = 0x13;
StringEncoder = 编码 UTF8
};

服务器
DataReceived + = Server_DataReceived ;

IniciaServico ();
}



Form赋予Load后,在server.Start(ip,8080)行执行StartService给出异常;



  私人   无效    IniciaServico  ()  
{

IPAddress ip = IPAddress 解析 " 10.10.5.27" );
服务器
开始 ip < span class ="pln"style ="margin:0px; padding:0px; border:0px; font-style:inherit; font-variant:inherit; font-weight:inherit; line-height:inherit; font-family:inherit ; vertical-align:baseline; color:#303336"> 8080 );

Habilita false );

txtStatus
文字 + = "Serviçotivo..." ;
}

注意在端口8910上使用Ip 127.0.0.1有效,但我需要与之通信这个Ip 10.10.5.27


   

解决方案

我要尝试的第一件事是连接到10.10.5.27从命令提示符下使用telnet。



telnet 10.10.5.27 8080



< span style ="font-size:14px">如果你无法连接,我会验证防火墙是否阻止访问,并验证服务是否可用,没有端口8080。


I am using SimpleTcpServer in a Windows Forms Application and when I use an IPAddress 10.10.5.27 Port 8080 gives Exception System.Net.Sockets.SocketException

The Form starts with the following statement below:

private void Form1_Load(object sender, EventArgs e)
    {
        this.Hide();
        this.WindowState = FormWindowState.Minimized;

        server = new SimpleTcpServer
        {
            //server.Delimiter = 0x13;
            StringEncoder = Encoding.UTF8
        };

        server.DataReceived += Server_DataReceived;

        IniciaServico();
    }

After the Form gives a Load executes the StartService giving exception on the server.Start (ip, 8080) line;

private void IniciaServico()
    {

        IPAddress ip = IPAddress.Parse("10.10.5.27");
        server.Start(ip, 8080);

        Habilita(false);

        txtStatus.Text += "Serviço ativo...";
    }

Note to use Ip 127.0.0.1 on port 8910 works, but I need to communicate with this Ip 10.10.5.27

     

解决方案

The first thing I would try is to connect to the 10.10.5.27 with telnet from a command prompt.

telnet 10.10.5.27 8080

if you can not connect I would verify the firewall is not blocking access and also verify the service is available no port 8080.


这篇关于C#SimpleTcpServer无法识别IPAddress的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆