PDA

View Full Version : Server design questions



Koas
1st March 2012, 10:20
Hi everyone! I want to write a server program in Qt, and I would like to ask for some advice before I get my hands into coding.

The idea is: there will be clients, running in final user's computers, behind firewalls, routers, etc... I want to be able to communicate with this clients through a web page (send a request and receive a response). Obviously, the web server can't connect directly to these clients.

What I'm planning to do is write a server program, let's call it "proxy"; clients will connect to it and say "Hi! I'm client #X, here is my auth data, validate it and I'll stay connected to you ok?". When a user enters the web and want to retrieve any data from a client, the web server will connect to this "proxy" and send a message like "Tell client #X to send me this data". The "proxy" will send that message to the connected client, wait for the response and send the response back to the web server.

I hope I've been able to explain the idea right. So, here are my questions:

- First of all, is this design correct? Is there anything already out there that does what I need? I don't want to reinvent the wheel :)

- After reading a lot of posts here about server networking, I'm planning to write it without threads, using the asynchronous socket functions of Qt. Is there any way to know how many clients I can serve with this approach? In case I reach this limit, what should I do? Span another server process using another port, create some threads and divide the clients amog them? Maybe even another machine?

Thanks a lot for your time! :)

ChrisW67
1st March 2012, 23:12
Obviously, the web server can't connect directly to these clients. No, but the clients can connect to the server and once connected data can flow both ways.

You planning to write a HTTP proxy server, and you don't think you are reinventing the wheel?

Koas
2nd March 2012, 15:10
Well yes, I thought about proxy servers but what I need it's not that, I need a web server to connect to a program in an user computer, only when a request to the web server is made. Thus, I need the program in the user computer to be available all the time. What a proxy server does is:

- Receive a request from user.
- Retrieve the requested data.
- Send it to the user.

What I need is:

- A user loads a web page.
- The web server requests some data from another user's computer.
- The web server shows the data to the first user in a web page.