简体   繁体   English

Winsock 2 DLL的C#包装器?

[英]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, ie 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. 现在,Silverlight 5(RC)支持P / Invoke ,我正在考虑使用服务器功能实现Socket类,即实现Bind,Listen,Accept方法等的类。使用P / Invoke,我将能够访问我的Silverlight类库中ws2_32.dll中的套接字方法。

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? 这是一个长期的尝试,但是:有没有人为Winsock 2 DLL实现C#包装程序,在这种情况下,这种工作是否可以公开获得?

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. 当然, Mono项目使用C#提供了自己的Socket实现,但是至少可以说,此代码会带来一点点开销。 I am looking for a more light-weight solution, if there is any. 我正在寻找更轻巧的解决方案(如果有)。

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 不确定这是否是您要查找的内容,但是在http://www.pinvoke.net/default.aspx/ws2_32.bind#上,您可以找到所需的签名,只需在网站左侧查找即可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# . 这个http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4043&lngWId=10似乎是Winsock2的VB实现包装器,可由C#使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM