سؤال

I have client server program for transfer of data using windsock but i need something like a client - channel - server in which channel will retrieve the request from the clinet or server will process it and id at that time channel is busy it will store that request in a queue. i want channel as a separate application. I have a little idea about this like:

class ch {

void getdata{
//to recieve data
}

void putdata{
//to send data
}

void queue{
//to store if channel is busy now
} 

private:
void dataaddress;
double datasize;

}

i thought of making it as a different application or as a dll file but i have no clue how to do it with dll file and other if i do it with socket it will be same like client or server. So is there a better way do it or somewhere to start? i know about boost:asio and other libraries but i need something in standard libraries of c++.

هل كانت مفيدة؟

المحلول

If I understand you, you want three programs, connected as follows:

+--------+       +-----------+       +--------+
| Client | <---> | "Channel" | <---> | Server |
+--------+       +-----------+       +--------+

The "channel" program is acting as a proxy between the server and the clients.

For this to work you have to create the "channel" program to act as both server and client. It acts as a server in the way that the client programs connect to it instead of the actual server. When the "channel" program receives a new client connection, it acts as a client by itself connecting to the real server.

Then you have to keep track if the socket pairs (client and server connections) so that when you receive input from one socket, you process it and send the processed data on to the other socket. So if a client sends data, you receive it in the "channel" program and do whatever processing is needed, and then send it on to the real server. And the same for the other way round.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top