Socket.Select butI have only Int32 socket-descriptors...

  • Thread starter Thread starter Dario
  • Start date Start date
D

Dario

I have an unmanaged library that handle many TCP/IP connections.
In my .NET application i want to test if there is input available
on these connections.
Using an existing function of the unmanaged library I'm able to retrieve
the list of Int32 socket-descriptors handled by the unmanaged library.
How can I use this list of Int32 socket-descriptors inside my C# program
to test if there is input available on these socket-descriptors?

I want to use the Socket.Select method of .NET
but this method wants a list of Socket
and I have only a list of Int32.

There is some manner to transform an Int32 socket-descriptor
into a Socket so I will be able to use Socket.Select?

Thanks for the help

-- Dario
 
Dario said:
I have an unmanaged library that handle many TCP/IP connections.
In my .NET application i want to test if there is input available
on these connections.
Using an existing function of the unmanaged library I'm able to retrieve
the list of Int32 socket-descriptors handled by the unmanaged library.
How can I use this list of Int32 socket-descriptors inside my C# program
to test if there is input available on these socket-descriptors?

I want to use the Socket.Select method of .NET
but this method wants a list of Socket
and I have only a list of Int32.

There is some manner to transform an Int32 socket-descriptor
into a Socket so I will be able to use Socket.Select?

Thanks for the help

-- Dario

Any suggestion?
 
Dario said:
I have an unmanaged library that handle many TCP/IP connections.
In my .NET application i want to test if there is input available
on these connections.
Using an existing function of the unmanaged library I'm able to retrieve
the list of Int32 socket-descriptors handled by the unmanaged library.
How can I use this list of Int32 socket-descriptors inside my C# program
to test if there is input available on these socket-descriptors?

I want to use the Socket.Select method of .NET
but this method wants a list of Socket
and I have only a list of Int32.

There is some manner to transform an Int32 socket-descriptor
into a Socket so I will be able to use Socket.Select?
I'm afraid there is no way I am aware of...it is likely not possible.
However, you could probably write a small piece of Managed C++ that performs
the select operation for you while exposing a nicer interface than PInvoke.
That unfortunatly is the only path I see(and that is basically all
Socket.Select does, wraps arround the native select call).

However, if anyone from MS is reading this, exposing support directly for
socket descriptors is of some use in interop situations!
 
However, if anyone from MS is reading this, exposing support directly
for socket descriptors is of some use in interop situations!

Yes, but if you're doing interop, then you can do the interop to check the
socket descriptors directly.

We definately don't need the framework classes cluttered up with interop
calls for every imaginable situation (not to mention that that makes the
classes unportable!)

Mark
 
Mark said:
Yes, but if you're doing interop, then you can do the interop to check the
socket descriptors directly.

We definately don't need the framework classes cluttered up with interop
calls for every imaginable situation (not to mention that that makes the
classes unportable!)

Not nessecerly, Every socket runtime I know of uses a descriptor for
sockets, thats pretty standard. What the descriptor contains is irrelevent.
Beyond that, the feature certainly doesn't have to exist IN the socket
class, I just hate re-writing functionality that the framework already does,
quite literally, because they didn't expose the proper method.
If you look at the Socket.Select method, it converts the list of Sockets
into descriptors and passes them to the native select(the berkely one it
seems, not WSASelect). Now because there is no way to access that directly,
You are going to end up writing pretty close to identical code just because
they take sockets and convert them. Its a minor annoyance. However it
doesn't break portability any more than SetSocketOpt does.
It is far less annoying than the screwed up file naming rules for creating
file streams, but annoying none the less.
 
Back
Top