Networks for Android

I am new to Android development. I am writing an application that will talk to the server over TCP / IP. I planned to use the java.net.Socket package, but then I discovered that there is Android. .LocalSocket network too. Does anyone know the difference between them or have a suggestion when to use which one.

thanks

+4
source share
2 answers

java.net.Socket is for creating TCP / IP sockets.

android.net.LocalSocket is designed to create unix domain sockets in an abstract namespace or in the file system. They are used for interaction between processes.

You need to use java.net.Socket, as you say, you need TCP / IP sockets.

+3
source

Did you consider checking API links first? Here is the definition of java.net.Socket and android.net.LocalSocket . The latter is described as "Creates a (non-server) socket in the UNIX domain namespace. The interface here is not at all like the java.net.Socket interface"; the obvious difference is that it has a single public LocalSocket() constructor.

0
source

All Articles