Search code examples
c#silverlightsocketspinvokewinsock2

C# wrapper for Winsock 2 DLL?


Now that Silverlight 5 (RC) supports P/Invoke, I am thinking of implementing a Socket class with server functionality, i.e. a class that implements the Bind, Listen, Accept methods, etc. With P/Invoke, I would be able to access the socket methods in ws2_32.dll from my Silverlight class library.

If possible, I would like to get a head start. It's a long-shot, but: has anyone implemented a C# wrapper to the Winsock 2 DLL, and in that case, is this effort publicly available?

The Mono project of course provides its own Socket implementation in C#, but this code comes with a little bit of overhead, to say the least. I am looking for a more light-weight solution, if there is any.


Solution

  • not sure whether this is what you are looking for but on http://www.pinvoke.net/default.aspx/ws2_32.bind# you can find the signatures you are looking for, just look on the left side of the site for ws2_32

    EDIT - after comments:

    This http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4043&lngWId=10 seems to be a VB-implemented wrapper for Winsock2 which can be used by C# .