我创建了一个新表单,并在顶部做了:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Collections;
using System.Net.Sockets;
namespace mws
{
public partial class Chat : Form
{
TcpListener serverSocket = new TcpListener(8888);
在新的 TcpListener(8888) 下,我看到绿线,警告是:
警告 4 'System.Net.Sockets.TcpListener.TcpListener(int)' is obsolete: '"This method has been deprecated. Please use TcpListener(IPAddress localaddr, int port) instead.
尝试谷歌,但我没有找到任何解决方案。 尝试做:new TcpListener(8888,21) 可能使用一个端口,但这不是解决方案。
最佳答案
var serverSocket = new TcpListener(IPAddress.Any, 8888);
关于c# - 我该如何解决有关 TcpListener : Please use TcpListener(IPAddress localaddr, int port) 的警告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28155702/