开发者

android: Connect two devices with a SSL connection

i want to connect two device using a SSL connection.[ Sake of clarity: these 2 devices are on same Local area OR wi-fi network, there is no internet connection and also there is no server OR some 3rd bridging device].

i tried to connect those device by using SSLSocket:

SocketFactory socketFactory = SSLSocketFactory.getDefault(); Socket socket = socketFactory.createSocket("hostname", 6575);

            socket.bind(new SocketAddress() {
                private static final long serialVersionUID = 1L;
            });

But i am getting connection refused error. Here is the error message that i get开发者_如何学Python in the logcat:

java.net.ConnectException: /192.168.1.34:6575- Connection refused

Please suggest,is there something wrong in the implementation OR i need to follow a different approach.

thanks!!


Make sure none of the devices are listening on localhost but instead listening on their ip address. In my case the error was caused by the fact that the server was listening on localhost and the emulator was trying to connect to the localhost, in this case the emulator and server's localhost is a different address.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜