Tcpclient, TcpListener, NetworkStream - Client/Server Security

I will be using Tcpclient, TcpListener, NetworkStream for my Client/Server application which will support 200-1000 users (lots of data and lots of bandwith).

The question is what is the best way to handle security?  I want the data from the client to be encrypted and secure when traveling across the network.  What is the best way to achieve this and can you provide some code that will show an example of a basic tcpclient securing data before shooting it off to a server and the tcplistener on the server (multi-threaded if possible) taking the data then unsecuring it so it can read the data.

Thank you.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I have no sample code for you right now, but what you might do, and what I know have been implemented before:
(Assuming you build the connection already)

Sender:EncryptPackage using

don.t press tab and space :D heheh

ok.. continued:

Sender: Encrypt data using it's own 'secret-sender-encrypt' method
Receiver: Encrypt data using it's own 'secret-receiver-encrypt' method and sending it back to sender
Sender: Decrypt using it 'secret-sender-decrypt' method and send to receiver again
Receiver: Decrypt using it 'secret-receiver-decrypt' method and read it.. this should be the original data..

You will see this causes more communication, but I think security will always have it's price.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You might also try out the SSLStream obj:

        Dim client As New System.Net.Sockets.TcpClient()
        Dim myStream As New System.Net.Security.SslStream(client.GetStream())

you might find this discussion interesting as well:
HepenAuthor Commented:
That example is really not that complete. It is just up in the air it seems.

Also do I have to have a certificate that loads from a file to use the SSLstream?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.