The best way to send a GET request is to use a high-level API. With Spring Boot this is currently WebClient, which replaced the older RestTemplate (see also tutorials such as: https://www.baeldung.com/spring-5-webclient or https://docs.spring.io/spring-boot/docs/3.0.x/reference/html/io.html#io.rest-client.webclient).
To call a server you need a URL such as <scheme>:<scheme-specific-part>
. As you say you want a GET call I assume you mean a HTTP GET call, which makes the either <scheme>
the protocol http
or https
and the <scheme-specific-part>
takes the form //<server-address>:<port>
. So in a simple scenario where you run the server socket on your localhost you could use something like http://localhost:<port>/<path>
, where <port>
is the port the ServerSocket listens to and <path>
is the resource you want to GET.
Of course, a ServerSocket is very low-level. It's much more convenient to use either a higher-level API such as a HttpServlet or a high-level API such as RestController, which means to just provide another Spring Boot application for the server part.