简体   繁体   中英

C / C++ code communicates with a remote web service on server (tomcat)

I have C++ HTTP code on the client side which will communicate with a remote web service on the server side.
The server is Tomcat Apache server which is configured on port 8080. The webservice which I have to access through my C++ http code is at:

http://somehostname:8080/some_path/some_api 

Is this possible?

1st confusion: I know that HTTP POST requests are sent on port 80 and here I have port 8080.

2nd confusion: The server is Tomcat Apache and the server code(webservice) is in java . This means that I have to access that java code through my C++ HTTP POST method. Is it possible to communicate C++ HTTP POST method to JAVA?

what i know that HTTP request(POST) is sent on port 80 and here i have port 8080

An application can use any available/free port. By convention certain ports are used by specific applications. Eg usually HTTP servers run on port 80 but they can also run on 8080 or any other port.

the server is tomcat server and the server code(webservice) is in java that means the i have to access that java code through my c++ HTTP POST method is it possible to communicate c++ HTTP POST method to JAVA ??

Yes it is possible.
You are essentially sending an HTTP message that the receiving side ie the Java application can "understand" it since it will be formed according to the HTTP standard (an HTTP message has a specific format).
All in all an HTTP message is plain text.

You should note though that in general there are many pitfalls when you try to communicate a C++ application with a Java application as there are subtle differences eg Java's lack of unsigned primitives compared to C++ etc

Yes it's possible.

  1. Just configure the c++ client with a url endpoint as per your example.
  2. Yes a c++ client can communicate with a Java server using HTTP. HTTP POST is not java or c++ specific.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM