开发者

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


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.


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().

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜