Moh'd Awad
Moh'd Awad

Reputation: 1768

How do i connect java socket client to multiple servers

I'm trying to connect client to more than 1 server Ex:4 servers to divide data in client side on servers number then send them to servers and get the result (distributed System)

Upvotes: 0

Views: 1138

Answers (1)

BadZen
BadZen

Reputation: 4274

You can't. One socket per connection. Have your client make multiple sockets if you want to connect to multiple servers - you could then either multiplex these using an nio Selector, or use a thread-per-connection model to marshal data messages to a client controller.

Here's a good intro to network programming (most of the concepts carry over directly to Java): Beej's Guide to Network Programming

There's also: The Java Networking Basics Trail

Upvotes: 2

Related Questions