Zircon socket defined

definition

Socket - a bidirectional transmission stream IPC

Overview

Sockets are bidirectional streaming. Channel different from the socket only movement data (the handle does not move).

description

Data zx_socket_write()end] to the socket, and by [ zx_socket_read()] is read from the other opposite end.

Once created, both ends of the socket is writable and readable. By passing ZX_SOCKET_SHUTDOWN_READ and ZX_SOCKET_SHUTDOWN_WRITE option parameter to the function [ zx_socket_shutdown()], it can be turned off to read and / or write functions of the socket end.

Attributes

The following properties can be queried from the socket object:

ZX_PROP_SOCKET_RX_THRESHOLD socket read size threshold, expressed in bytes. When the number of bytes queued on the socket (for read) is equal to or greater than this value, then the transmission ZX_SOCKET_READ_THRESHOLD signal. By disabling the read default threshold signal (after setting, the value of this property is written as 0 to disable it).

ZX_PROP_SOCKET_TX_THRESHOLD socket write size threshold value, in bytes. When the space on the socket for equal write or greater than this value, * ZX_SOCKET_WRITE_THRESHOLD ** transmission signal. Write threshold signaling is disabled by default (when set, writing the value of this property to 0 to disable it).

From the perspective view of the socket handle, the received data is to use the buffer contains [ zx_socket_read()] function read from the handle (the opposite direction has been written by the handle). And the data transmission buffer is included
by [ zx_socket_write()] are written to the handle (by the end of reading of the handle).

signal

Socket object signal may be provided the following:

ZX_SOCKET_READABLE sockets have readable data

ZX_SOCKET_WRITABLE data can be written to the socket

ZX_SOCKET_PEER_CLOSED other end of this socket is closed.

ZX_SOCKET_PEER_WRITE_DISABLED permanently closed end of the write operation, the local settings may be ZX_SOCKET_SHUTDOWN_READ operation, or to set up the peer ZX_SOCKET_SHUTDOWN_WRITE . Off before writing, in writing data to the socket, whereby the socket can still successfully read.

ZX_SOCKET_WRITE_DISABLED permanently closed end of this write operation, it may be provided by the local ZX_SOCKET_SHUTDOWN_WRITE , or to set up the peer ZX_SOCKET_SHUTDOWN_READ .

ZX_SOCKET_CONTROL_READABLE data can be read from the control plane socket

ZX_SOCKET_CONTROL_WRITABLE data may be a control plane to the socket.

ZX_SOCKET_SHARE by [ zx_socket_share()] send socket.

ZX_SOCKET_ACCEPT by [ zx_socket_accept()] receiving socket.

ZX_SOCKET_READ_THRESHOLD queued waiting to read data on the socket exceeds the read threshold value.

ZX_SOCKET_WRITE_THRESHOLD space available for writing on the socket exceeds a write threshold value.

System calls

  • [ zx_socket_accept()] - receiving socket through the socket
  • [ zx_socket_create()] - New socket
  • [ zx_socket_read()] - read data from socket
  • [ zx_socket_share()] - Sharing socket through the socket
  • [ zx_socket_shutdown()] - Do not read or write operation
  • [ zx_socket_write()] - writing data to the socket

Guess you like

Origin blog.csdn.net/sinat_20184565/article/details/93907247