Create a Socket from a IntPtr handle

  • Thread starter Thread starter Stuart Ferguson
  • Start date Start date
S

Stuart Ferguson

I currently have a service which is written using C++/MFC and this
service calls multiple dlls. This service uses these dlls to pass
messages to another service via sockets.

I am about to write one of these dlls in c# however the service
currently passes a handle to a socket created in the service to allow
the dll to send a message. Is there a way of creating a socket in the
c# dll similar to the Attach method of the CSocket class.

Any help would be appreciated.

Stuart
 
Stuart,

No, there isn't anything in the Socket class that will let you pass a
handle to an existing socket and use that.

However, you can use the WinSock API functions through the P/Invoke
layer, and work with the handle that is passed to you.

Hope this helps.
 
Back
Top