I am learning about Java socket. I am trying to send an HTTPS GET request to Facebook, like this:
String request = \"GET / HTTP/1.0\\r\\n\"
+
Two answers.
You are trying to talk to an HTTPS server. That requires you to establish an SSL/TLS channel. That is >>really difficult<< to do on a plain socket ... you'd have to implement the connection negotiation, the client-side validation of the key chain, the session encryption / decryption, and so on.
A more sane way would be to use SSLSocket, SSLSocketFactory and so on to handle the SSL/TLS stuff ... but it is still a bit tricky.
Talking to an HTTP or HTTPS service over a Socket is not a sensible approach. You are not really going to learn much by doing it, because the normal way to talk to an HTTP / HTTPS service from Java is to use HttpURLConnection
, or the Apache HTTP libraries if you want more control.