Use the chrome.socket API to send and receive data over the network using TCP and UDP connections. Note: Starting with Chrome 33, this API is deprecated in favor of the 'sockets.udp', 'sockets.tcp' and 'sockets.tcpServer' APIs.
Use the chrome.socket API to send and receive data over the network using TCP and UDP connections. Note: Starting with Chrome 33, this API is deprecated in favor of the 'sockets.udp', 'sockets.tcp' and 'sockets.tcpServer' APIs. * available since Chrome 30 * https://developer.chrome.com/apps/socket
(accept socket-id)
This method applies to TCP sockets only. Registers a callback function to be called when a connection is accepted on this listening server socket. Listen must be called first. If there is already an active accept callback, this callback will be invoked immediately with an error as the resultCode.
|socket-id| - The socketId.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [accept-info] where:
|accept-info| - https://developer.chrome.com/apps/socket#property-callback-acceptInfo.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
This method applies to TCP sockets only. Registers a callback function to be called when a connection is accepted on this listening server socket. Listen must be called first. If there is already an active accept callback, this callback will be invoked immediately with an error as the resultCode. |socket-id| - The socketId. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [accept-info] where: |accept-info| - https://developer.chrome.com/apps/socket#property-callback-acceptInfo. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/socket#method-accept.
(bind socket-id address port)
Binds the local address for socket. Currently, it does not support TCP socket.
|socket-id| - The socketId. |address| - The address of the local machine. |port| - The port of the local machine.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [result] where:
|result| - https://developer.chrome.com/apps/socket#property-callback-result.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Binds the local address for socket. Currently, it does not support TCP socket. |socket-id| - The socketId. |address| - The address of the local machine. |port| - The port of the local machine. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [result] where: |result| - https://developer.chrome.com/apps/socket#property-callback-result. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/socket#method-bind.
(connect socket-id hostname port)
Connects the socket to the remote machine (for a tcp socket). For a udp socket, this sets the default address which packets are sent to and read from for read() and write() calls.
|socket-id| - The socketId. |hostname| - The hostname or IP address of the remote machine. |port| - The port of the remote machine.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [result] where:
|result| - https://developer.chrome.com/apps/socket#property-callback-result.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Connects the socket to the remote machine (for a tcp socket). For a udp socket, this sets the default address which packets are sent to and read from for read() and write() calls. |socket-id| - The socketId. |hostname| - The hostname or IP address of the remote machine. |port| - The port of the remote machine. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [result] where: |result| - https://developer.chrome.com/apps/socket#property-callback-result. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/socket#method-connect.
(create type)
(create type options)
Creates a socket of the specified type that will connect to the specified remote machine.
|type| - The type of socket to create. Must be tcp or udp. |options| - The socket options.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [create-info] where:
|create-info| - https://developer.chrome.com/apps/socket#property-callback-createInfo.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Creates a socket of the specified type that will connect to the specified remote machine. |type| - The type of socket to create. Must be tcp or udp. |options| - The socket options. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [create-info] where: |create-info| - https://developer.chrome.com/apps/socket#property-callback-createInfo. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/socket#method-create.
(destroy socket-id)
Destroys the socket. Each socket created should be destroyed after use.
|socket-id| - The socketId.
Destroys the socket. Each socket created should be destroyed after use. |socket-id| - The socketId. https://developer.chrome.com/apps/socket#method-destroy.
(disconnect socket-id)
Disconnects the socket. For UDP sockets, disconnect is a non-operation but is safe to call.
|socket-id| - The socketId.
Disconnects the socket. For UDP sockets, disconnect is a non-operation but is safe to call. |socket-id| - The socketId. https://developer.chrome.com/apps/socket#method-disconnect.
(get-info socket-id)
Retrieves the state of the given socket.
|socket-id| - The socketId.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [result] where:
|result| - https://developer.chrome.com/apps/socket#property-callback-result.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Retrieves the state of the given socket. |socket-id| - The socketId. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [result] where: |result| - https://developer.chrome.com/apps/socket#property-callback-result. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/socket#method-getInfo.
(get-joined-groups socket-id)
Get the multicast group addresses the socket is currently joined to.
|socket-id| - The socketId.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [groups] where:
|groups| - https://developer.chrome.com/apps/socket#property-callback-groups.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/socket#method-getJoinedGroups.
Get the multicast group addresses the socket is currently joined to. |socket-id| - The socketId. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [groups] where: |groups| - https://developer.chrome.com/apps/socket#property-callback-groups. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/socket#method-getJoinedGroups.
(get-network-list)
Retrieves information about local adapters on this system.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [result] where:
|result| - https://developer.chrome.com/apps/socket#property-callback-result.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/socket#method-getNetworkList.
Retrieves information about local adapters on this system. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [result] where: |result| - https://developer.chrome.com/apps/socket#property-callback-result. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/socket#method-getNetworkList.
(join-group socket-id address)
Join the multicast group and start to receive packets from that group. The socket must be of UDP type and must be bound to a local port before calling this method.
|socket-id| - The socketId. |address| - The group address to join. Domain names are not supported.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [result] where:
|result| - https://developer.chrome.com/apps/socket#property-callback-result.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Join the multicast group and start to receive packets from that group. The socket must be of UDP type and must be bound to a local port before calling this method. |socket-id| - The socketId. |address| - The group address to join. Domain names are not supported. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [result] where: |result| - https://developer.chrome.com/apps/socket#property-callback-result. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/socket#method-joinGroup.
(leave-group socket-id address)
Leave the multicast group previously joined using joinGroup. It's not necessary to leave the multicast group before destroying the socket or exiting. This is automatically called by the OS.Leaving the group will prevent the router from sending multicast datagrams to the local host, presuming no other process on the host is still joined to the group.
|socket-id| - The socketId. |address| - The group address to leave. Domain names are not supported.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [result] where:
|result| - https://developer.chrome.com/apps/socket#property-callback-result.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Leave the multicast group previously joined using joinGroup. It's not necessary to leave the multicast group before destroying the socket or exiting. This is automatically called by the OS.Leaving the group will prevent the router from sending multicast datagrams to the local host, presuming no other process on the host is still joined to the group. |socket-id| - The socketId. |address| - The group address to leave. Domain names are not supported. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [result] where: |result| - https://developer.chrome.com/apps/socket#property-callback-result. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/socket#method-leaveGroup.
(listen socket-id address port)
(listen socket-id address port backlog)
This method applies to TCP sockets only. Listens for connections on the specified port and address. This effectively makes this a server socket, and client socket functions (connect, read, write) can no longer be used on this socket.
|socket-id| - The socketId. |address| - The address of the local machine. |port| - The port of the local machine. |backlog| - Length of the socket's listen queue.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [result] where:
|result| - https://developer.chrome.com/apps/socket#property-callback-result.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
This method applies to TCP sockets only. Listens for connections on the specified port and address. This effectively makes this a server socket, and client socket functions (connect, read, write) can no longer be used on this socket. |socket-id| - The socketId. |address| - The address of the local machine. |port| - The port of the local machine. |backlog| - Length of the socket's listen queue. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [result] where: |result| - https://developer.chrome.com/apps/socket#property-callback-result. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/socket#method-listen.
(read socket-id)
(read socket-id buffer-size)
Reads data from the given connected socket.
|socket-id| - The socketId. |buffer-size| - The read buffer size.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [read-info] where:
|read-info| - https://developer.chrome.com/apps/socket#property-callback-readInfo.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Reads data from the given connected socket. |socket-id| - The socketId. |buffer-size| - The read buffer size. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [read-info] where: |read-info| - https://developer.chrome.com/apps/socket#property-callback-readInfo. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/socket#method-read.
(recv-from socket-id)
(recv-from socket-id buffer-size)
Receives data from the given UDP socket.
|socket-id| - The socketId. |buffer-size| - The receive buffer size.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [recv-from-info] where:
|recv-from-info| - https://developer.chrome.com/apps/socket#property-callback-recvFromInfo.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Receives data from the given UDP socket. |socket-id| - The socketId. |buffer-size| - The receive buffer size. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [recv-from-info] where: |recv-from-info| - https://developer.chrome.com/apps/socket#property-callback-recvFromInfo. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/socket#method-recvFrom.
(secure socket-id)
(secure socket-id options)
Start a TLS client connection over a connected TCP client socket.
|socket-id| - The connected socket to use. |options| - Constraints and parameters for the TLS connection.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [result] where:
|result| - https://developer.chrome.com/apps/socket#property-callback-result.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Start a TLS client connection over a connected TCP client socket. |socket-id| - The connected socket to use. |options| - Constraints and parameters for the TLS connection. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [result] where: |result| - https://developer.chrome.com/apps/socket#property-callback-result. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/socket#method-secure.
(send-to socket-id data address port)
Sends data on the given UDP socket to the given address and port.
|socket-id| - The socketId. |data| - The data to write. |address| - The address of the remote machine. |port| - The port of the remote machine.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [write-info] where:
|write-info| - https://developer.chrome.com/apps/socket#property-callback-writeInfo.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Sends data on the given UDP socket to the given address and port. |socket-id| - The socketId. |data| - The data to write. |address| - The address of the remote machine. |port| - The port of the remote machine. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [write-info] where: |write-info| - https://developer.chrome.com/apps/socket#property-callback-writeInfo. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/socket#method-sendTo.
(set-keep-alive socket-id enable)
(set-keep-alive socket-id enable delay)
Enables or disables the keep-alive functionality for a TCP connection.
|socket-id| - The socketId. |enable| - If true, enable keep-alive functionality. |delay| - Set the delay seconds between the last data packet received and the first keepalive probe. Default is 0.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [result] where:
|result| - https://developer.chrome.com/apps/socket#property-callback-result.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/socket#method-setKeepAlive.
Enables or disables the keep-alive functionality for a TCP connection. |socket-id| - The socketId. |enable| - If true, enable keep-alive functionality. |delay| - Set the delay seconds between the last data packet received and the first keepalive probe. Default is 0. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [result] where: |result| - https://developer.chrome.com/apps/socket#property-callback-result. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/socket#method-setKeepAlive.
(set-multicast-loopback-mode socket-id enabled)
Set whether multicast packets sent from the host to the multicast group will be looped back to the host.Note: the behavior of setMulticastLoopbackMode is slightly different between Windows and Unix-like systems. The inconsistency happens only when there is more than one application on the same host joined to the same multicast group while having different settings on multicast loopback mode. On Windows, the applications with loopback off will not RECEIVE the loopback packets; while on Unix-like systems, the applications with loopback off will not SEND the loopback packets to other applications on the same host. See MSDN: http://goo.gl/6vqbjCalling this method does not require multicast permissions.
|socket-id| - The socketId. |enabled| - Indicate whether to enable loopback mode.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [result] where:
|result| - https://developer.chrome.com/apps/socket#property-callback-result.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/socket#method-setMulticastLoopbackMode.
Set whether multicast packets sent from the host to the multicast group will be looped back to the host.Note: the behavior of setMulticastLoopbackMode is slightly different between Windows and Unix-like systems. The inconsistency happens only when there is more than one application on the same host joined to the same multicast group while having different settings on multicast loopback mode. On Windows, the applications with loopback off will not RECEIVE the loopback packets; while on Unix-like systems, the applications with loopback off will not SEND the loopback packets to other applications on the same host. See MSDN: http://goo.gl/6vqbjCalling this method does not require multicast permissions. |socket-id| - The socketId. |enabled| - Indicate whether to enable loopback mode. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [result] where: |result| - https://developer.chrome.com/apps/socket#property-callback-result. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/socket#method-setMulticastLoopbackMode.
(set-multicast-time-to-live socket-id ttl)
Set the time-to-live of multicast packets sent to the multicast group.Calling this method does not require multicast permissions.
|socket-id| - The socketId. |ttl| - The time-to-live value.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [result] where:
|result| - https://developer.chrome.com/apps/socket#property-callback-result.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/socket#method-setMulticastTimeToLive.
Set the time-to-live of multicast packets sent to the multicast group.Calling this method does not require multicast permissions. |socket-id| - The socketId. |ttl| - The time-to-live value. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [result] where: |result| - https://developer.chrome.com/apps/socket#property-callback-result. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/socket#method-setMulticastTimeToLive.
(set-no-delay socket-id no-delay)
Sets or clears TCP_NODELAY for a TCP connection. Nagle's algorithm will be disabled when TCP_NODELAY is set.
|socket-id| - The socketId. |no-delay| - If true, disables Nagle's algorithm.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [result] where:
|result| - https://developer.chrome.com/apps/socket#property-callback-result.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Sets or clears TCP_NODELAY for a TCP connection. Nagle's algorithm will be disabled when TCP_NODELAY is set. |socket-id| - The socketId. |no-delay| - If true, disables Nagle's algorithm. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [result] where: |result| - https://developer.chrome.com/apps/socket#property-callback-result. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/socket#method-setNoDelay.
(tap-all-events chan)
Taps all valid non-deprecated events in chromex.app.socket namespace.
Taps all valid non-deprecated events in chromex.app.socket namespace.
(write socket-id data)
Writes data on the given connected socket.
|socket-id| - The socketId. |data| - The data to write.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [write-info] where:
|write-info| - https://developer.chrome.com/apps/socket#property-callback-writeInfo.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Writes data on the given connected socket. |socket-id| - The socketId. |data| - The data to write. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [write-info] where: |write-info| - https://developer.chrome.com/apps/socket#property-callback-writeInfo. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/socket#method-write.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close