I want to design an application that receives messages via TCPIP from different
ports, and after some processing these messages are going to make changes
to a database located on another machine. I want high performance for this
application. There are some questions about this that I hope someone can
help me with.

1) The connection to the data base is a critical point. The database is tuned,
but there might be much time consumed waiting while the database call is
managed, compared to other tasks. An idea would be to let other threads work
during the blocking time. Is there any way to get around this problem? One
thread per message is not a solution, I suppose.

2) If i have understood .Net one should have one TCPListener connected to
each port, and one thread for each tcplistener, to avoid blocking. But if
there are many ports, and if i want to get high performance according to
1) there can be a lot of threads. How many threads is recommended, I mean,
there must be some limit when switching between threads consumes more time
than the gain is of it?

3)Are there any difference in performance using thread pools compared to
ordinary threads?