private void StartReceivingData(string ipAddress, int iPort)
{
try
{
if (!_bContinueReciving)
{
//initializeMainSocket(ipAddress, iPort);
_mSocket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);//<------HERE IS RAISED THE EXCEPTION
_mSocket.Bind(new IPEndPoint(IPAddress.Parse(ipAddress), iPort));
// _mSocket.Bind(new IPEndPoint(IPAddress.Loopback, iPort));
_mSocket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.HeaderIncluded, true);
_mSocket.IOControl(IOControlCode.ReceiveAll, new byte[4] { 1, 0, 0, 0 }, new byte[4] { 0, 0, 0, 0 });
//var 1
_mSocket.BeginReceive(_buffReceivedData, 0, _buffReceivedData.Length, SocketFlags.None,
new AsyncCallback(OnReceive), null);
initializeLocalSocket();
}
else
{
_bContinueReciving = false;
_mSocket.Close();
}
}
catch (Exception exception)
{
Debug.WriteLine(exception);
}
}
I don't understand why...it worked and now it doesn't. could someone help me? i am streaming with vlc, and i wan't to receive the packets, do some reports, and then restream local to a player
I ran into this in a Web App on Azure when attempting to connect to Blob Storage. The problem turned out to be that I had missed deploying a connection string for the blob storage so it was still pointing at the storage emulator. There must be some retry logic built into the client because I saw about 3 attempts. The /devstorageaccount1
here is a dead giveaway.
Fixed by properly setting the connection string in Azure.
I had a similar problem but I fixed it with by doing some changes in firewall setting.
You can follow the below steps
Inside Windows Firewall, click on "Allow a program or feature through Windows Firewall"
Now inside of Allow Programs, Click on "Change Settings" button. Once you clicked on Change Settings button, the "Allow another program..." button gets enabled.
Click on "Allow another program..." button , a new dialog box will be opened. Choose the programs or application for which you are getting the socket exception and click on "Add" button.
Click OK, and restart your machine.
Try to run your application (which has an exception) with administrative rights.
I hope this helps.
Peace,
Sunny Makode
I had the same error happening when I had two different ASP.net projects in two different Visual Studio instances.
Closing one of them fixed the issue.
This is the error that is returned when the Windows Firewall blocks the port (out-going). We have a strict web server so the outgoing ports are blocked by default. All I had to do was to create a rule to allow the TCP port number in wf.msc.
Well I don't even understand the culprit of this problem. But in my case the problem is totally different. I've tried running netstat -o
or netstat -ab
, both show that there is not any app currently listening on port 62434 which is the one my app tries to listen on. So it's really confusing to me.
I just tried thinking of what I had made so that it stopped working (it did work before). Well then I thought of the Internet sharing I made on my Ethernet adapter with a private virtual LAN (using Hyper-v in Windows 10). I just needed to turn off the sharing and it worked just fine again.
Hope this helps someone else having the same issue. And of course if someone could explain this, please add more detail in your own answer or maybe as some comment to my answer.
I'm developing an UWP application which connects to a MQTT broker in the LAN. I go a similar error.
MQTTnet.Exceptions.MqttCommunicationException: 'An attempt was made to access a socket in a way forbidden by its access permissions [::ffff:xxx.xxx.xxx.xxx]:1883'
ExtendedSocketException: An attempt was made to access a socket in a way forbidden by its access permissions [::ffff:xxx.xxx.xxx.xxx]:1883
Turned out that I forgot to give the app the correct capabilites ...
IIS was the main offender for me. My IIS was running and it restrains any new socket connections from opening.
The problem resolved for me by stopping IIS by running the command "iisreset -stop
"
Reload Visual Studio with Administrator privileges. Windows Sockets (WinSock) will not allow you to create a SocketType.RAW Socket without Local Admin. And remember that your Solution will need elevated privileges to run as expected!
Running iisreset
in a command window fixed it for me.
I've had this problem when trying to start a dotnet Core project using dotnet run when it tried to bind to the port.
The problem was caused by having a Visual Studio 2017 instance running with the project open - I'd previously started the project via VS for debugging and it appears that it was holding on to the port, even though debugging had finished and the application appeared closed.
Closing the Visual Studio instance and running "dotnet run" again solved the problem.
Source: Stackoverflow.com