is there any possibility to create a server based on java that connects to another server…my main objective is to have a main SERVER connected by a sub server that transfer data to the main SERVER.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is possible. Server is just a java Program. You might need to create two thread in this program. One to handle communication with clients and other to handle communication with sub server. (You need to create thread per sub server). In this thread you can send/recieve data to/from client/subserver.
MAIN SERVER
You Main server will be multithreaded with each thead dealing with individual subserver. Each thread will have socket which will be connected to respective subserver. By threading. I mean you will perform all read/write operation to/from subserver in the run method of this thread.
SUB SERVER
If you have single client then you need to create two threads. One to communicate with MainServer and other to communicate with client. Similar each thread will have socket connection of respective entity. In case of multiple client, you need to create multiple thread each to handle request from particular client.
We need to use thread because there will be multiple sub servers and multiple client running at the same time.