Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am getting following error "An attempt was made to access a socket in a way forbidden by its access permissions"

when i execute the tcplistener.start(). I am trying to sniff my IIS website.(my TcpListner and IIS having same port)
Posted
Updated 8-May-11 14:54pm
v2
Comments
Pete O'Hanlon 8-May-11 17:00pm    
Without seeing any code, it's hard to say what the problem is other than it's likely that you are hitting an issue where the account that IIS is running in and the account that the code that's trying to access it have security restrictions on them.

i did not get any luck from above.

basically i have a website (lets say using port 90) and i have a tcp listner (a console application) which is monitoring the request coming to that port.
TcpListener tcplistener = new TcpListener(port);
reportMessage("Listening on port "+ port);
tcplistener.Start();// hit error here.
while (true)
{
//do some thing
}

thanks for the help in advance.
 
Share this answer
 
v2
Comments
BobJanova 10-May-11 9:45am    
You should edit your original question or post comments to it, not post a solution.
A listener? On the same machine as the website? That should fail because of trying to start two server sockets on the same port, but apparently there is some magic that makes that not be the case nowadays[^]. So I would guess that you aren't allowed to do that to combine with a socket started by a different process.

I'd also direct you to the note in that topic:
By default, multiple listeners can listen to a specific port. However, only one of the listeners can perform operations on the network traffic sent to the port. If more than one listener attempts to bind to a particular port, then the one with the more specific IP address handles the network traffic sent to that port. You can use the ExclusiveAddressUse property to prevent multiple listeners from listening to a specific port.

That is, you can't listen in to requests and still have them processed by the original destination, anyway. To do that you need to hook into the network stack which I believe requires P/Invoke calls.
 
Share this answer
 
If you really just need to sniff your site, why don't you use wireshark[^] ?
 
Share this answer
 
v2
 
Share this answer
 
netstat -a -b
find your port and application which use it
shutdown this application
if you use 80 it can be skype

if you need sniff on 80 port set iis port to for example 8080
start you application on 80 port
in your application connect to iis 8080 for every request and send response on 80 port
 
Share this answer
 
v2
Comments
CHill60 30-Jan-15 6:41am    
Question is over 3 years old and already has an accepted answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900