C++ Poco Libraires TCP Server

sindhu hegde
sindhu hegde used Ask the Experts™
on
My application consists of  GUI application, an  application which resides on controller  and the server application. I am developing my application with C++ for the Poco libraries. The controller should communicate with the GUI and the server through the TCP /IP protocol. So My question here is whether I need to setup my GUI as server? If some one can forward me the sample of TCPServer created with Poco libraries which listens to specific ip adress and port.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
the GUI is a client application and not a server. and it is the GUI which communicates with the server and not the other way round.

check POCO class ServerApplication at  pocoproject.org/docs/Poco.Util.ServerApplication.html how to setup either a Windows Service or a Unix daemon for your TCP Server.

Sara

Author

Commented:
how I want is GUI and server listen to the same port. So when the controller connects to the server it connects to GUI also. I could not find any sample application which shows the server application listening on specific port and ip address I tried GUI as client but it will not connect to the controller.

Author

Commented:
Sorry forgot to explain GUI and server listening to same port and ip address.
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Author

Commented:
More detailed explanation I have server onep 10 .6. 168.45, second server on 10.6.168.44,  the controller will have ip 10.6.168.12. both the server can listen to the same port on the controller and responds with messages to the controller.
Top Expert 2016

Commented:
as the name GUI (graphical user interface) implies it is not listening on a port (a thread of the GUI application can do, though) but waits for user input. if using TCP you can't have 2 programs listening to same ip and port because only one of them will be able to catch messages.

you need to do client-server communication, which means that the server is listening to a socket for ip and port and if a client requests connection and was accepted by the server, the latter creates a new socket which client and server then could use to exchange data.

what is the purpose of the 'controller' application? how many computers are involved? what is the task the gui should do? do you want to be able to invoke the controller or is the controller a background application already started? Do you want to stop server (and controller?) by user request? or do you want to display results evaluated by controller/server?

note, even if the GUI is only for output, it should be started as client, then create asynchronously running thread that connects to server or controller in order to get a connection where the results could be sent to GUI.

Sara
Top Expert 2016

Commented:
I have server on ip 10 .6. 168.45, second server on 10.6.168.44,  the controller will have ip 10.6.168.12. both the server can listen to the same port on the controller and responds with messages to the controller.

the servers are 'clients' to the controller in the scenario you described. they are not listening to 10.6.168.12 but connect to 10.6.168.12 controller which actually is 'server'. after connection they could exchange data.

can you describe what GUI, controller and servers actually are doing ?

Sara

Author

Commented:
. So here is my application overview  There are three application GUI which is a web server, server application has sql database on it and  controller is a realtime application which send the result as the tool runddowns happens.
The GUI  webserver is to accept user settings and relay it to the controller and display the results from the controller.
The controller generates the results as the rundown of the tools happen.
The server application which the controller connects to  stores the result in the database.

After talking to you i realized that I am looking this is in wrong way. I might have to open up another port from the controller which connects to the GUI for displaying results and accepting the settings from the GUI application.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial