473,795 Members | 2,667 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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

Jul 21 '05 #1
7 2462
Dario wrote:
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?

Jul 21 '05 #2
Dario wrote:
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?

Jul 21 '05 #3

"Dario" <da***@despamme d.com> wrote in message
news:bm******** **@fata.cs.inte rbusiness.it...
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!
Thanks for the help

-- Dario

Jul 21 '05 #4

"Dario" <da***@despamme d.com> wrote in message
news:bm******** **@fata.cs.inte rbusiness.it...
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!
Thanks for the help

-- Dario

Jul 21 '05 #5
"Daniel O'Connell" <onyxkirx@--NOSPAM--comcast.net> wrote in
news:Ufsib.5536 77$cF.233183@rw crnsc53:
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
Jul 21 '05 #6

"Mark" <mark@--somewhere--.com> wrote in message
news:Xn******** *************** *******@207.46. 248.16...
"Daniel O'Connell" <onyxkirx@--NOSPAM--comcast.net> wrote in
news:Ufsib.5536 77$cF.233183@rw crnsc53:
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!)


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.

Mark

Jul 21 '05 #7
shiretu
1 New Member
Check out Socket.Select static method. It is in .NET 1.0, 1.1 and 2.0. It should do the job
Jul 30 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
8739
by: DreJoh | last post by:
I've read many articles on the subject and the majority of them give the same solution that's in article 821625 on the MSDN website. I'm using the following code and when a the client disconnects the child socket remains in the CLOSE_WAIT state. Anyone have any idea what's missing? ----------------------------- Socket Code ----------------------------- namespace Sockets { #region Class - SocketClient
8
21913
by: Grant Richard | last post by:
Using the TcpListener and TcpClient I created a program that just sends and receives a short string - over and over again. The program is fine until it gets to around 1500 to 1800 messages. At that time, I get a SocketException with the message "Only one usage of each socket address (protocol/network address/port) is normally permitted". This happen if you use localhost or between two distinct computers. And, for a period of time after the...
4
7091
by: zbcong | last post by:
Hello: I write a multithread c# socket server,it is a winform application,there is a richtextbox control and button,when the button is click,the server begin to listen the socket port,waiting for a incoming connection,the relative code snipprt as following:: private IPAddress myIP=IPAddress.Parse("127.0.0.1"); private IPEndPoint myServer; private Socket socket; private Socket accSocket; private System.Windows.Forms.Button button2;...
2
26521
by: zhebincong | last post by:
Hello: I write a multithread c# socket server,it is a winform application,there is a richtextbox control and button,when the button is click,the server begin to listen the socket port,waiting for a incoming connection,the relative code snipprt as following:: private IPAddress myIP=IPAddress.Parse("127.0.0.1");
0
2062
by: Vladimir Lushnikov | last post by:
Hi, I'm experimenting with the Seqpacket protocol, because the connectionless protocols aren't enough for my needs, and TCP/IP doesn't preserve message boundaries. This is what I've currently got in C# -------------------------------------------------------------------------- listeningSock = new Socket(AddressFamily.InterNetwork, SocketType.Seqpacket, ProtocolType.Unknown);
0
4693
by: Macca | last post by:
Hi, I am writing an asychronous socket server to handle 20+ simulataneous connections. I have used the example in MSDN as a base. The code is shown at end of question. Each connection has a number of different types of data coming in. I have a databuffer for each type of data coming in.
11
7731
by: hazz | last post by:
smtpClient.Send(message) is causing me problems as per specifics in the trace below. Email is sent but not without this error typically upon sending the second email, but sometimes when running the app, even the first time. The application will be required to be sending out repeated emails, about one every second or two. Must this be done asynchronously? Thank you. -Greg I get the generic error messages;
4
5866
by: Kevin | last post by:
I got the following error when revieving data from a server. hostSystem.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host at System.Net.Sockets.Socket.Receive(Byte buffer, Int32 offset, Int32 size, SocketFlags socketFlags) This error only happens when the long time recieving data, in this case 50 seconds. It looks to me like a time out error. I have an j++ application which does the same...
1
17552
by: Mr. Beck | last post by:
Hello, Please Help..... I have been working with some tcp/ip socket communication within a C# program recently. Basicly, I have a program (myProblemProgram) that has a socket connected to another program for information passing. Upon receiving a particular "command" from the the information passing program, myProblemProgram will launch a separate thread to do individual communication with another file transfer program. The thread...
5
15729
by: Arno | last post by:
reposted with the right microsoft managed newsgroup ID: Sorry for the inconvinience Hi, I've written a class for client-socket connection, but I get a lot of times the error message "Unable to read data from the transport connection" when restart reading the stream with socket.BeginRead in the Sub SocketIncomingMsg. I'm debugging now for weeks, but I can't detect where it's
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10436
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10163
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.