Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An attempt was made to access a socket in a way forbidden by its access permissions. Why?

 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

like image 322
andrew Avatar asked May 05 '12 11:05

andrew


2 Answers

I restarted this service : Host Network Service on windows Services program. And it worked.

You can run these commands in the windows terminal instead, as @admin mentioned in comment section:

net stop hns net start hns 
like image 167
Parsa Avatar answered Nov 09 '22 23:11

Parsa


Most likely the socket is held by some process. Use netstat -o to find which one.

like image 45
stark Avatar answered Nov 09 '22 22:11

stark