Reputation: 21
What if the difference between Android LocalServerSocket
and Java ServerSocket
?
Do they have the same function?
I think LocalServerSocket is Java implementation for Linux ServerSocket
,Java ServerSocket
implements itself. So LocalServerSocket
and ServerSocket
have the same function. Am I right? Thanks.
Upvotes: 2
Views: 836
Reputation: 2420
I faced the question and I found lots of amazing stuff.
ServerSocket
: waits for requests to come in over the network. It performs some operation based on that request, and then possibly returns a result to the requester.
It uses network protocols for communications.
LocalServerSocket
: Creates a new server socket listening at specified name. On the Android platform, the name is created in the Linux abstract namespace (instead of on the filesystem).
socket family is used to communicate between processes on the same machine efficiently. Traditionally, UNIX domain sockets can be either unnamed, or bound to a filesystem pathname (marked as being of type socket). Linux also supports an abstract namespace which is independent of the filesystem.
Socket permissions have no meaning for abstract sockets: the process umask has no effect when binding an abstract socket, and changing the ownership and permissions of the object (via fchown and fchmod) has no effect on the accessibility of the socket. Abstract sockets automatically disappear when all open references to the socket are closed. The abstract socket namespace is a nonportable Linux extension.
There is differences between these two in Communications and Permissions.
More Information :
http://man7.org/linux/man-pages/man7/unix.7.html
https://developer.android.com/reference/android/net/LocalServerSocket
https://developer.android.com/reference/java/net/ServerSocket
Upvotes: 1