views:

197

answers:

3

I'm not too familiar with networking in JAVA but what i'm basically trying to do is create a couple of threads that will "talk" to each other using HTTPS for security reasons.

I'm not sure about the terminology so what I'm looking for is a pointing in the right direction. Hopefully, this should be pretty easy for experienced JAVA networking programmers.

I've tried to research this myself but there are different methods of doing this (HttpsURLConnection? Sending a POST Request Using a URL?) and a tip from someone who's done this before could save me alot of research time.

Thanks!

+4  A: 

HttpsURLConnection is indeed the main class, but for simple uses you can actually just do:

InputStream is = new URL("https://example.com").openStream();

Consider whether you actually want to use HTTP for your application. It may make more sense to use another protocol, or raw SSL. Look at SSLSocket, SSLServerSocket, and the associated classes.

Java RMI (Remote Method Invocation) may also be relevant. It allows calling Java methods on remote computers, and has built-in security options. See Using RMI with SSL if you're interested in that route.

Matthew Flaschen
+1  A: 

If you want to stick with Http, have a look at the apache httpclient library.Its has a lot of useful http abstractions.

Jimmy
A: 

Check out the awesome project called Netty. It provides unified API for various transport types and already has an HTTP codec. Adding HTTPS support to your application is not so complicated with it.

Artyom Sokolov