I'm having a problem when declaring a TCPListener in C# 2010 Express, and it is causing me a little hassle. It gives me this error when I declare one and I am not quite sure why?

The type or namespace name 'TCPListener' could not be found (are you missing a using directive or an assembly reference?)

I have:

using System.Net.Sockets;

In my code, but I feel I am missing something..

My TCPListener Code:

TCPListener tcpListener = new TCPListener(111);

The strange thing is that this happens in both Visual C# Express 2010 and Visual C# Express 2008 which renders me unable to use the code at all..

And before saying re-install I have done that with 2010 to no avail. so if anybody has any hints/solutions etc. could they please reply.

Thanks in advance.

Recommended Answers

All 4 Replies

The name of class should be: System.Net.Sockets.TcpListener

Okay thanks. :D

I think you should have something like:

using System.Net;
using System.Net.Sockets;

And then:

IPAddress localAddr = IPAddress.Parse("127.0.0.1");
TcpListener tcpListener = new TcpListener(localAddr,111);

Yeah, I have it working now. Thanks guys :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.