tags:

views:

99

answers:

1

Hi,

I have situation where I have to handle multiple live UDP streams in the server.

I have two options (as I think)

Single Socket : 1) Listen at single port on the server and receive the data from all clients on the same port and create threads for each client to process the data till the client stop sending. Here only one port is used to receive the data and number of threads used to process the data.

Multiple Sockets : 2) Client will request open port from the server to send the data and the application will send the open port to the client and opens a new thread listening at the port to receive and process the data.Here for each client will have unique port to send the data.

I already implemented a way to know which packet is coming from which client in UDP.

I have 1000+ clients and 60KB data per second I am receiving.

Is there any performance issues using the above methods

or Is here any efficient way to handle this type of task in C ?

Thanks,

Raghu

A: 

With that many clients, having one thread per client is very inefficient since lots and lots of context switches must be performed. Also, the number of ports you can open per IP is limited (port is a 16 bit number).

Therefore "Single Socket" will be far more efficient. But you can also use "Multipe Sokets" with just a single thread using the asynchronous API. If you can identify the client using the package's payload, then there is no need to have a port per client.

Lawnmower