Link to home
Start Free TrialLog in
Avatar of parabellum
parabellum

asked on

Connect to multiple Tcp Servers


Hello.

I want to connect to multiple TCP/IP servers at the same time.(Different IPs, same port)

When there is one server  my code is like:
TcpClient = new TcpClient()
client.GetStream().BeginRead(readBuffer, 0, 1024, newAsyncCallback(GetFromServer), null);

Now for multiple servers do i need to create  a TcpClient list ? Do i need to worry about thread safety ?

Frankly i could not decide how to design.
ASKER CERTIFIED SOLUTION
Avatar of kris_per
kris_per

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kris_per
kris_per


Above sample doesn't need to do anything special for thread safety. But depending on further requirement (that will make threads to update a shared variable), then you need to consider thread-safetry issues.