Both are possible. Sockets sit in the TCP network communication layer. RMI is part of the software application, specifically an invocation layer for calling methods of a remote object. RMI has the benefits of making it easy in your code to invoke remote methods on
Java objects (it only works between applications in Java, so consider the RMI IIOP if you need inter-platform cooperation). RMI does have some overheads because of the generic protocol it uses, so you can make some savings by writing your own more targeted protocol over sockets. But then you need to assess if the overheads are really worth the effort, and if you might need to expand the code later and what impact that would have.
Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / Amazon Amazon UK )