0

I have a question about SocketChannels in Android. This is my code:

SocketChannel socketChannel = SocketChannel.open();
socketChannel.connect(new InetSocketAddress("127.0.0.1", 90));

This code works in Java but not in Android. I always get an IOException My first problem was the first line. I had to add permissions to open sockets. The first line now works but the second line doesn't. I always get an IOException.

Any suggestions?

Martin
  • 313
  • 1
  • 3
  • 12

2 Answers2

2

127.0.0.1? you try to connect to your android device with socket 90. I don't think your device has open up such port for your program to connect.

xandy
  • 27,357
  • 8
  • 59
  • 64
0

try opening the socket on the physical device. your probably running it on the emulator and that port isnt opened.

j2emanue
  • 60,549
  • 65
  • 286
  • 456