How can I resolve the warning about TcpListener: use TcpListener (IPAddress localaddr, int port) instead?

I created a new form and at the top did:

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);

In the new TcpListener (8888), I see a green line, and a warning:

Warning 4 'System.Net.Sockets.TcpListener.TcpListener (int)' is deprecated: '' This method is deprecated. Use TcpListener (IPAddress localaddr, int port) instead.

I tried Google, but I did not find any solution. Tried to do: the new TcpListener (8888,21) may use the port, but this is not a solution.

+4
source share
1 answer
var serverSocket = new TcpListener(IPAddress.Any, 8888);
+11
source

All Articles