English 中文(简体)
Could not be performed exception using a socket to do a UDP Multicast
原标题:

When running a C# app I created on XP it runs just fine, but under Windows 7, I get the following error:

"An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full"

I am doing the following:

socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
IPAddress localIPAddr = IPAddress.Any;
EndPoint localEP = new IPEndPoint(localIPAddr, MulticastPort);
socket.Bind(localEP);
MulticastOption mcastOption = new MulticastOption(MulticastAddress, localIPAddr);

socket.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, mcastOption);

byte[] bytes = new Byte[40960];

The error happens on the second last line socket.SetSocketOption(...)

You ll notice I m doing UDP multicasting, is there something I need to do for Windows 7 to allow this?

问题回答

IIRC, joining a multicast group does require an additional privilege since you are modifying a kernel level table. I cannot recall which privilege it is though.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签