I'm trying to include a network listening module in my application developed in C#. For that I created a socket like this
IPAddress ipAd = IPAddress.Parse("192.168.1.185");
/* Initializes the Listener */
TcpListener myList = new TcpListener(ipAd, 5027);
/* Start Listeneting at the specified port */
myList.Start();
Console.WriteLine("The server is running at port 5027...");
Console.WriteLine("The local End point is :" +
myList.LocalEndpoint);
Console.WriteLine("Waiting for a connection.....");
Socket s = myList.AcceptSocket();
Console.WriteLine("Connection accepted from " + s.RemoteEndPoint);
But I have the following error in execution: 'An attempt was made to access a socket in a way forbidden by its access permissions'
can anyone please help me with this problem,
Thank you for your help.
A socket error 10013 can be caused by the antivirus or firewall software. Basically, a needed socket connection is being denied. Socket error 10013 is a message which implies that a port is blocked and/or unreachable.
I would suggest you to disable antivirus software and Firewall together (as a test) on the computer temporarily and try connecting and check if it works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.