1

我正在尝试为 Linux 现金服务器设计一个界面本地网站,我正在使用带有 c# 的 asp.net,起初我只是尝试建立一个测试连接,我用两个文本框和一个标签制作一个底部,这是我的代码:

     public partial class _Default : System.Web.UI.Page
   {
     protected void Page_Load(object sender, EventArgs e)
   {

  }
      private Socket clientSocket;
      private IPAddress hostAddress;


  private void telnetSocketAsyncEventArgs_Completed(object sender, SocketAsyncEventArgs      e)
 {
try
{
    if (e.SocketError == SocketError.Success)
    {
        if (e.LastOperation == SocketAsyncOperation.Connect)
        {
            errorplace.Text="Service Is Running";
        }
    }
    else
    {
        errorplace.Text="Service Is not Running";
    }
}
catch (SocketException ex )
{

    errorplace.Text = ex.Message;
}
    }
  protected void Button1_Click1(object sender, EventArgs e)
   {
{

try
{
    if (string.IsNullOrEmpty(IPTextBox.Text))
        return;

    if (string.IsNullOrEmpty(PortTextBox.Text))
        return;

    int port;
    hostAddress = Dns.GetHostEntry(IPTextBox.Text).AddressList[0];
    int.TryParse(PortTextBox.Text, out port);

    if (hostAddress.AddressFamily == AddressFamily.InterNetwork)
        clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
    else if (hostAddress.AddressFamily == AddressFamily.InterNetworkV6)
        clientSocket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp);

    SocketAsyncEventArgs telnetSocketAsyncEventArgs = new SocketAsyncEventArgs();
    telnetSocketAsyncEventArgs.RemoteEndPoint = new IPEndPoint(hostAddress, port);
    telnetSocketAsyncEventArgs.Completed += new
        EventHandler<SocketAsyncEventArgs>(telnetSocketAsyncEventArgs_Completed);

    clientSocket.ConnectAsync(telnetSocketAsyncEventArgs);
}
catch (SocketException )
{
   errorplace.Text="Service Is not Running";

}
finally
{
}

}


  }
    }

我对代码调试没有任何问题,但是当我每次尝试连接其所说的“服务未运行”时,我需要帮助,我只想确定 asp.net 是否在运行 linux 服务器好?所以我可以继续我的项目?

4

0 回答 0