array of tcp connections
hello everyone,
I want to creat an array of servers to connect to (configurable hots:port) and send a command to be invoked like "something\n"
then close the tcp connection? whereis a good place to start reading about this or maybe a snip of code or two like the array part at least, I would be greatful. Any references is great... thank you.
# 1
It's so simple, I don't know where's your problem actually. Simply create a collection of server information (host address and port), iterate over the collection, establish a socket connection to the server in every step, and finally send your command.
# 3
> I am pretty new with tcp and java stuff never done
> it... that is why i am asking... ive only dont things
> with oracle...
Then I wouldn't be worrying about arrays because that's the very least of your problems.
See this http://java.sun.com/docs/books/tutorial/networking/index.html
# 4
I think reading the manual and learning would be a much better choice than asking for a very specific case, as it improves your knowledge and skill. Read these and you will be able to write your own stuff:
Socket documentation:
http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html
Collections framework documentation:
http://java.sun.com/j2se/1.5.0/docs/guide/collections/reference.html
Tutorial on how to use Sockets:
http://java.sun.com/docs/books/tutorial/networking/sockets/index.html