Sockets, to be continued...

S

Steven

Hi,

Thanks all for you help with my "socket and buffer size" question.
I have decided to use async ones, and my code is working pretty well.

But i still have a non-answered question:

Is it a problem if all the client are connected and sending a large quantity
of bytes simultaneously to the same port of the server ?

In fact, each client is sending bytes (a value from 1 to 100 wich is the
result of an internal calculation) without any interruption to the server
(something like each second), which have to write out on a form the values
received from each client (represented as a slidebar graduated from 1 to 100
for each client for example)...

Somewhere on the net i saw that it's better to have one port by client, but
it sounds strange to me, indeed, i haven't seen any example like this ??!

Thanks again.
 
W

Willy Denoyette [MVP]

| Hi,
|
| Thanks all for you help with my "socket and buffer size" question.
| I have decided to use async ones, and my code is working pretty well.
|
| But i still have a non-answered question:
|
| Is it a problem if all the client are connected and sending a large
quantity
| of bytes simultaneously to the same port of the server ?
|
Not a problem, after all you only have a single wire don't you? The
framelevel (below IP) protocol arranges that only one client can send a
stream (1 up to framelength bytes) at a time.

| In fact, each client is sending bytes (a value from 1 to 100 wich is the
| result of an internal calculation) without any interruption to the server
| (something like each second), which have to write out on a form the values
| received from each client (represented as a slidebar graduated from 1 to
100
| for each client for example)...
|
| Somewhere on the net i saw that it's better to have one port by client,
but
| it sounds strange to me, indeed, i haven't seen any example like this ??!
|

What you read is BS, a port identifies a service, like port 25 which
identifies an SMTP service by convention. Multiple clients (thousands) will
use the same port to send their mail message to.
Probably, they (or you) are confusing sockets with ports.

Willy.
 
S

Sharon

Hi,
I've encountered the same problem(?) when implementing async server.
I still don't know which way is better:
1. connect and transfer data on the same port.
2. connect on the same port and assign a unique port for data transfer.

It's true that this question is not relevant to the hardware level,
as there is only one wire.
But isn't there a potential bottle neck on the software level when using
the same port for data transfer?
Sharon.
 
W

Willy Denoyette [MVP]

Hmm.. are you sure you aren't confusing ports with sockets?
A server listens on a port (actually it binds a socket to a port), when a
connection request arrives at that port, you duplicate the socket and go
back to listen for new connection requests, while you use the duplicated
socket to handle the actual data transfer.

Willy.

| Hi,
| I've encountered the same problem(?) when implementing async server.
| I still don't know which way is better:
| 1. connect and transfer data on the same port.
| 2. connect on the same port and assign a unique port for data transfer.
|
| It's true that this question is not relevant to the hardware level,
| as there is only one wire.
| But isn't there a potential bottle neck on the software level when using
| the same port for data transfer?
| Sharon.
|
|
| | >
| > | > | Hi,
| > |
| > | Thanks all for you help with my "socket and buffer size" question.
| > | I have decided to use async ones, and my code is working pretty well.
| > |
| > | But i still have a non-answered question:
| > |
| > | Is it a problem if all the client are connected and sending a large
| > quantity
| > | of bytes simultaneously to the same port of the server ?
| > |
| > Not a problem, after all you only have a single wire don't you? The
| > framelevel (below IP) protocol arranges that only one client can send a
| > stream (1 up to framelength bytes) at a time.
| >
| > | In fact, each client is sending bytes (a value from 1 to 100 wich is
the
| > | result of an internal calculation) without any interruption to the
| > server
| > | (something like each second), which have to write out on a form the
| > values
| > | received from each client (represented as a slidebar graduated from 1
to
| > 100
| > | for each client for example)...
| > |
| > | Somewhere on the net i saw that it's better to have one port by
client,
| > but
| > | it sounds strange to me, indeed, i haven't seen any example like this
| > ??!
| > |
| >
| > What you read is BS, a port identifies a service, like port 25 which
| > identifies an SMTP service by convention. Multiple clients (thousands)
| > will
| > use the same port to send their mail message to.
| > Probably, they (or you) are confusing sockets with ports.
| >
| > Willy.
| >
| >
|
|
 
S

Steven

Hi again Willy !

I'm not sure of what you're calling "wire", but the server is also sending
datas to the client, but only to the "selected" one.

Indeed, i have some clients (max 50) sending bytes (approx 600 bytes)
simultanously to the same port of the server, and the server is answering to
only one selected client, also via the same port.

Is this configuration correct ? Like Sharon asks (his english is much better
than mine !!) : "Isn't there a potential bottle neck on the software level
when using the same port for data transfer?"

Thanks !
 
C

Chris Mullins

Steven said:
Is it a problem if all the client are connected and sending a large
quantity of bytes simultaneously to the same port of the server ?

That's just fine. In fact, any other way would be wrong.

Just as long as each client has done a connect to the port, and has it's own
socket, you're fine.

Let's say you had "MagicService" listening on port 555. You then have 100
clients connect to this port and start sending data. In your server, you'll
have a collection of 100 sockets, each of which works exactly the way you
think it would.
Somewhere on the net i saw that it's better to have one port by client,
but it sounds strange to me, indeed, i haven't seen any example like this
??!

Whoever said that was.... wrong.
 
C

Chris Mullins

Steven said:
"Isn't there a potential bottle neck on the software level when using the
same port for data transfer?"

Nope, no problem at all. This is how TCP is supposed to work.

You listen on a port, accept incoming connections on that port, then send
and receive data to and from the client over that socket.

This method scales wel into the tens of thousands of simultanious connected
sockets...
 
N

Nick Hounsome

Willy Denoyette said:
| Hi,
|
| Thanks all for you help with my "socket and buffer size" question.
| I have decided to use async ones, and my code is working pretty well.
|
| But i still have a non-answered question:
|
| Is it a problem if all the client are connected and sending a large
quantity
| of bytes simultaneously to the same port of the server ?

There is a whole lot of misunderstanding going on here:

1. a port is just a number. It is not a port in the same sense as COM1 say
where you have a singular physical connection.
2. A logical TCP connection is a 4-tuple (client addr,client port,server
addr,server port) It is IMPOSSIBLE for there to be duplicates because the
client cannot attach the a port on its machine more than once.
3. The only physical port is the ethernet adapter. You will normally only
have one but you can add more in which case you will have more than one IP
address. The port numbers on the adapters are unrelated in any way.
4. Listening for connections is potentially a bottle neck since typically
only one thread can listen (I'm not sure that this is true for .NET but it
is for many implementations) but this only relates to connectuion NOT to
subsequent data transfer which will normally be done on different threads.
5. The result of all this is that it makes no difference whether the clients
connect to the same port or different ports.
 

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