6 Answers
6

Someone needs to listen for a connection somewhere. A standard Socket connection connects to a host and port on which there is an active listener (ServerSocket for standard Java socket). ServerSocket does, by default, block, waiting for incoming connections.

If you go with adding a ServerSocket connection on both clients, you would want to have one thread listening for connections and another attempting to make an outgoing connections. There are some alternatives, such as using NIO which would allow you to check for an incoming and outgoing connection without blocking your entire application.

You can also look into Broadcasting, however, there are complexities with that solution as well.

One more thought: Depending on your requirements you can always look into leveraging P2P frameworks such as JXTA.

No, they only can do it by initializing a server socket at least in one of the sides. After one of the clients establishes the connection then you can implement a protocol to write/read from both sides.
This is the mechanism to "wait" for connections, client sockets can't receive a connection if it has not been init by server socket first.

Idea, why don't you integrate a small HTTP server in both clients so that you know you can stick to the HTTP protocol (i.e: Jetty)