试图以访问权限禁止的方式访问套接字.为什么? [英] 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);
}
}
我不明白为什么......它起作用了,但现在不起作用了.有人可以帮助我吗?我正在使用 vlc 进行流式传输,但我不想接收数据包,做一些报告,然后将本地重新流式传输到播放器
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
推荐答案
很可能套接字由某个进程持有.使用 netstat -o
查找哪个.
Most likely the socket is held by some process. Use netstat -o
to find which one.
这篇关于试图以访问权限禁止的方式访问套接字.为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文