Multiple local ports in system.net.sockets class

J

jcprince

Hi

Not sure I can do what I'm trying to do without using a 3rd party
component like Dart. I need to build a windows service to create a
socket connection on an IBM mainframe using an IP and port
combination. No problem there.
However, due to the expected volume (at least 20x10K streams per
second in each direction), the mainframe sysadmin has requested the
service use multiple 'conversations' within the single IP connection.
The easiest way to do this is use different local ports when we open
the connection (Dart's component allows this), but I cannot find
anything within the .Net socket class which appears to support the
setting of a local port when opening a connection. Can this be done in
C# using the sockets class?

Thanks

John
 
P

Peter Duniho

[...]
However, due to the expected volume (at least 20x10K streams per
second in each direction), the mainframe sysadmin has requested the
service use multiple 'conversations' within the single IP connection.
The easiest way to do this is use different local ports when we open
the connection (Dart's component allows this), but I cannot find
anything within the .Net socket class which appears to support the
setting of a local port when opening a connection. Can this be done in
C# using the sockets class?

At the face of it, your question doesn't make much sense.

First, there's no such thing as an "IP connection". IP is a low-level
protocol on which TCP and UDP are implemented, and like UDP the IP
protocol is connectionless. So, let's assume you really mean "TCP
connection".

Second, using a different local port will by definition require a new TCP
connection. A TCP connection is uniquely identified by the two endpoints
IP address and port. A single TCP connection can only have a single port
at each end.

As far as defining the port used in .NET, once a Socket has been bound to
an address, that's its address. It can only have one address (IP address
plus port). You can use the Bind() method to specify the port explicitly,
or the port will be automatically assigned from the range of unused ports
when you connect the socket to a remote endpoint. But either way, the
Socket can only have one port assigned to it.

Finally, the way you've worded your question, you are limiting the
most-specific replies to coming from people who know what "Dart" is.
Knowing what "Dart" is is not a prerequisite to knowing how to use .NET
Sockets, and so you are unnecessarily limiting your potential audience by
comparing your problem to something "like Dart".

It would be better if, rather than just saying "like Dart", you explain
what "Dart" is and what specifically it does that you would like to be
able to do in .NET. I can tell you for sure that "Dart" in and of itself
cannot provide a way to use multiple local ports on a single TCP
connection, because that's a limitation of TCP. But other than that, I
can't really compare the behavior of "Dart" to what .NET can or cannot do.

If the above doesn't answer your question, you may want to rethink how to
describe what it is you're actually trying to do and what information
specifically it is you need.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top