Peter
Peter

Reputation: 153

Android networking

I'm new to android development I'm writing an application that will talk to a server over TCP/IP I was planning to use the java.net.Socket package but then I've found that there is a android.net.LocalSocket also. Does anyone know the difference between these or have a suggestion when to use which one of these.

Thanks

Upvotes: 4

Views: 507

Answers (2)

Goran Horia Mihail
Goran Horia Mihail

Reputation: 3645

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

android.net.LocalSocket is for creating unix domain sockets in the abstract namespace or on the filesystem. These are used for inter process communication.

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

Upvotes: 3

Michael De Silva
Michael De Silva

Reputation: 3818

Did you consider checking the API references first? Here's the definition for 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 entirely unlike that of java.net.Socket"; the obvious difference is it has a single public constructor LocalSocket().

Upvotes: 0

Related Questions