I have to make a java program in which there are some processes that communicate using HTTP
sockets. But I found that there are only TCP/UDP sockets in Java.
I am little bit confused here. Is there anything like HTTP Sockets
?
Is there any library in java that provides HTTP sockets
?
The processes in my program run on the same system spawned by a single main java program.
I need some way to communicate one process with the other.
Asked
Active
Viewed 71 times
0

sunny
- 5
- 3
-
HTTP uses TCP sockets at a lower level. Try using an HTTPClient library to send your requests – jr593 Mar 08 '21 at 10:45
-
as @jr593 mentioned HTTP protocol (application layer) is an upper layer working on top of Sockets (transport layer). Check https://stackoverflow.com/questions/15108139/difference-between-socket-programming-and-http-programming – carlosvin Mar 08 '21 at 10:51
-
Java has an [`HttpClient`](https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html) class in the `java.net.http` package, and an [`HttpServer`](https://docs.oracle.com/javase/8/docs/jre/api/net/httpserver/spec/com/sun/net/httpserver/HttpServer.html) class in the `com.sun.net.httpserver` package. HTTP may or may not be the most optimal choice for local IPC, depending on what you are trying to accomplish. What is wrong with using plain TCP with a custom protocol? – Remy Lebeau Mar 08 '21 at 19:17
-
This related [question](https://stackoverflow.com/questions/3732109/simple-http-server-in-java-using-only-java-se-api) gives code examples and Java APIs to implement an HTTP server. – CodeMonkey Jun 06 '21 at 17:25