【问题标题】:TcpListener does not contain a definition for "AcceptSocket"TcpListener 不包含“AcceptSocket”的定义
【发布时间】:2017-03-14 16:31:34
【问题描述】:

This is the error screenshot当我在 Vs2017 中编写 TcpClient-Server 程序时,出现以下问题。

Console.WriteLine("Waiting for a connection.....");     
Socket s=myList.AcceptSocket();
Console.WriteLine("Connection accepted from " + s.RemoteEndPoint);`

它说 TcpListner 不包含一个不包含这样的方法。 请帮忙。完整代码见https://www.codeproject.com/Articles/1415/Introduction-to-TCP-client-server-in-C

感谢和问候, T.S.

【问题讨论】:

  • 您是否错过了命名空间using System.Net.Sockets;using System.Net。我已经在 VS2015 上测试了代码。完全没有错误。请重新检查您的代码。
  • 你还是报错?
  • 嗨 active92,你能给我一个链接,因为我在 .net Core 上尝试这个可能不是运行它的 IDE。
  • @TonyStark 有链接吗?你是什​​么意思?我刚刚从您提供的链接中复制并粘贴了代码。
  • 是的,错误仍然存​​在

标签: c# visual-studio tcpclient tcpserver


【解决方案1】:

上面代码中发生的事情不是使用 .NET Framework Console 应用程序,而是使用的是 .NET Core,它不是导致错误的兼容版本。原因是 MS 站点对所有以前的程序都使用了 .NET Core,尽管这也是一样的。

【讨论】:

    猜你喜欢
    • 2012-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-27
    • 1970-01-01
    • 2017-08-19
    • 1970-01-01
    • 2014-04-03
    相关资源
    最近更新 更多