Use the chrome.sockets.udp API to send and receive data over the network using UDP connections. This API supersedes the UDP functionality previously found in the 'socket' API.
Use the chrome.sockets.udp API to send and receive data over the network using UDP connections. This API supersedes the UDP functionality previously found in the 'socket' API. * available since Chrome 33 * https://developer.chrome.com/apps/sockets.udp
(bind socket-id address port)
Binds the local address and port for the socket. For a client socket, it is recommended to use port 0 to let the platform pick a free port.Once the bind operation completes successfully, onReceive events are raised when UDP packets arrive on the address/port specified -- unless the socket is paused.
|socket-id| - The socket ID. |address| - The address of the local machine. DNS name, IPv4 and IPv6 formats are supported. Use '0.0.0.0' to accept packets from all local available network interfaces. |port| - The port of the local machine. Use '0' to bind to a free port.
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| - The result code returned from the underlying network call. A negative value indicates an error.
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 and port for the socket. For a client socket, it is recommended to use port 0 to let the platform pick a free port.Once the bind operation completes successfully, onReceive events are raised when UDP packets arrive on the address/port specified -- unless the socket is paused. |socket-id| - The socket ID. |address| - The address of the local machine. DNS name, IPv4 and IPv6 formats are supported. Use '0.0.0.0' to accept packets from all local available network interfaces. |port| - The port of the local machine. Use '0' to bind to a free port. 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| - The result code returned from the underlying network call. A negative value indicates an error. 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/sockets.udp#method-bind.
(close socket-id)
Closes the socket and releases the address/port the socket is bound to. Each socket created should be closed after use. The socket id is no longer valid as soon at the function is called. However, the socket is guaranteed to be closed only when the callback is invoked.
|socket-id| - The socket ID.
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 [].
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.
Closes the socket and releases the address/port the socket is bound to. Each socket created should be closed after use. The socket id is no longer valid as soon at the function is called. However, the socket is guaranteed to be closed only when the callback is invoked. |socket-id| - The socket ID. 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 []. 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/sockets.udp#method-close.
(create)
(create properties)
Creates a UDP socket with the given properties.
|properties| - The socket properties (optional).
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| - The result of the socket creation.
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/sockets.udp#method-create.
Creates a UDP socket with the given properties. |properties| - The socket properties (optional). 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| - The result of the socket creation. 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/sockets.udp#method-create.
(get-info socket-id)
Retrieves the state of the given socket.
|socket-id| - The socket ID.
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 [socket-info] where:
|socket-info| - Object containing the socket information.
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/sockets.udp#method-getInfo.
Retrieves the state of the given socket. |socket-id| - The socket ID. 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 [socket-info] where: |socket-info| - Object containing the socket information. 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/sockets.udp#method-getInfo.
(get-joined-groups socket-id)
Gets the multicast group addresses the socket is currently joined to.
|socket-id| - The socket ID.
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| - Array of groups the socket joined.
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/sockets.udp#method-getJoinedGroups.
Gets the multicast group addresses the socket is currently joined to. |socket-id| - The socket ID. 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| - Array of groups the socket joined. 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/sockets.udp#method-getJoinedGroups.
(get-sockets)
Retrieves the list of currently opened sockets owned by the application.
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 [socket-infos] where:
|socket-infos| - Array of object containing socket information.
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/sockets.udp#method-getSockets.
Retrieves the list of currently opened sockets owned by the application. 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 [socket-infos] where: |socket-infos| - Array of object containing socket information. 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/sockets.udp#method-getSockets.
(join-group socket-id address)
Joins the multicast group and starts to receive packets from that group. The socket must be bound to a local port before calling this method.
|socket-id| - The socket ID. |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| - The result code returned from the underlying network call. A negative value indicates an error.
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/sockets.udp#method-joinGroup.
Joins the multicast group and starts to receive packets from that group. The socket must be bound to a local port before calling this method. |socket-id| - The socket ID. |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| - The result code returned from the underlying network call. A negative value indicates an error. 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/sockets.udp#method-joinGroup.
(leave-group socket-id address)
Leaves the multicast group previously joined using joinGroup. This is only necessary to call if you plan to keep using the socketafterwards, since it will be done automatically by the OS when the socket is closed.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 socket ID. |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| - The result code returned from the underlying network call. A negative value indicates an error.
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/sockets.udp#method-leaveGroup.
Leaves the multicast group previously joined using joinGroup. This is only necessary to call if you plan to keep using the socketafterwards, since it will be done automatically by the OS when the socket is closed.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 socket ID. |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| - The result code returned from the underlying network call. A negative value indicates an error. 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/sockets.udp#method-leaveGroup.
(send socket-id data address port)
Sends data on the given socket to the given address and port. The socket must be bound to a local port before calling this method.
|socket-id| - The socket ID. |data| - The data to send. |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 [send-info] where:
|send-info| - Result of the send method.
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 socket to the given address and port. The socket must be bound to a local port before calling this method. |socket-id| - The socket ID. |data| - The data to send. |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 [send-info] where: |send-info| - Result of the send method. 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/sockets.udp#method-send.
(set-broadcast socket-id enabled)
Enables or disables broadcast packets on this socket.
|socket-id| - The socket ID. |enabled| - true to enable broadcast packets, false to disable them.
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| - The result code returned from the underlying network call.
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/sockets.udp#method-setBroadcast.
Enables or disables broadcast packets on this socket. |socket-id| - The socket ID. |enabled| - true to enable broadcast packets, false to disable them. 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| - The result code returned from the underlying network call. 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/sockets.udp#method-setBroadcast.
(set-multicast-loopback-mode socket-id enabled)
Sets 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 socket ID. |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| - The result code returned from the underlying network call. A negative value indicates an error.
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/sockets.udp#method-setMulticastLoopbackMode.
Sets 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 socket ID. |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| - The result code returned from the underlying network call. A negative value indicates an error. 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/sockets.udp#method-setMulticastLoopbackMode.
(set-multicast-time-to-live socket-id ttl)
Sets the time-to-live of multicast packets sent to the multicast group.Calling this method does not require multicast permissions.
|socket-id| - The socket ID. |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| - The result code returned from the underlying network call. A negative value indicates an error.
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/sockets.udp#method-setMulticastTimeToLive.
Sets the time-to-live of multicast packets sent to the multicast group.Calling this method does not require multicast permissions. |socket-id| - The socket ID. |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| - The result code returned from the underlying network call. A negative value indicates an error. 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/sockets.udp#method-setMulticastTimeToLive.
(set-paused socket-id paused)
Pauses or unpauses a socket. A paused socket is blocked from firing onReceive events.
|socket-id| - https://developer.chrome.com/apps/sockets.udp#property-setPaused-socketId. |paused| - Flag to indicate whether to pause or unpause.
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 [].
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/sockets.udp#method-setPaused.
Pauses or unpauses a socket. A paused socket is blocked from firing onReceive events. |socket-id| - https://developer.chrome.com/apps/sockets.udp#property-setPaused-socketId. |paused| - Flag to indicate whether to pause or unpause. 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 []. 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/sockets.udp#method-setPaused.
(tap-all-events chan)
Taps all valid non-deprecated events in chromex.app.sockets.udp namespace.
Taps all valid non-deprecated events in chromex.app.sockets.udp namespace.
(tap-on-receive-error-events channel & args)
Event raised when a network error occured while the runtime was waiting for data on the socket address and port. Once this event is raised, the socket is paused and no more onReceive events will be raised for this socket until the socket is resumed.
Events will be put on the |channel| with signature [::on-receive-error [info]] where:
|info| - The event data.
Note: |args| will be passed as additional parameters into Chrome event's .addListener call.
https://developer.chrome.com/apps/sockets.udp#event-onReceiveError.
Event raised when a network error occured while the runtime was waiting for data on the socket address and port. Once this event is raised, the socket is paused and no more onReceive events will be raised for this socket until the socket is resumed. Events will be put on the |channel| with signature [::on-receive-error [info]] where: |info| - The event data. Note: |args| will be passed as additional parameters into Chrome event's .addListener call. https://developer.chrome.com/apps/sockets.udp#event-onReceiveError.
(tap-on-receive-events channel & args)
Event raised when a UDP packet has been received for the given socket.
Events will be put on the |channel| with signature [::on-receive [info]] where:
|info| - The event data.
Note: |args| will be passed as additional parameters into Chrome event's .addListener call.
https://developer.chrome.com/apps/sockets.udp#event-onReceive.
Event raised when a UDP packet has been received for the given socket. Events will be put on the |channel| with signature [::on-receive [info]] where: |info| - The event data. Note: |args| will be passed as additional parameters into Chrome event's .addListener call. https://developer.chrome.com/apps/sockets.udp#event-onReceive.
(update socket-id properties)
Updates the socket properties.
|socket-id| - The socket ID. |properties| - The properties to update.
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 [].
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/sockets.udp#method-update.
Updates the socket properties. |socket-id| - The socket ID. |properties| - The properties to update. 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 []. 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/sockets.udp#method-update.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close