Android LocalServerSocket

后端 未结 4 1515
长发绾君心
长发绾君心 2021-02-02 02:02

In android, there are two classes LocalServerSocket and LocalSocket. I think they are something like AF_LOCAL in unix socket (I am not sure it is correct or not).

My que

4条回答
  •  死守一世寂寞
    2021-02-02 02:15

    Thanks for the answers here. Piecing people's responses together, the things to be careful about are

    On the native side:

    1. the name of the socket must have a 0-byte value as the first character
    2. The linux man page is right in that 0 bytes are NOT treated as a null terminator.
    3. The man page is not clear in its meaning when it states that "the rest of the bytes in sunpath" are used. "Rest of bytes" is determined by the length passed in for sockaddr_len and Android sets this per the recommended file-system sockets of sizeof(sa_family_t) + strlen(sun_path) + 1. This is important when making calls to bind, connect, etc!

    On the Java side:

    Android defines the conventions it uses under the covers but are consistent with above.

提交回复
热议问题