Version1 /
udp-socket Module(redirected from VersionCurrent.Udp-socket) This module supports sending and receiving UDP (datagram) messages. Unlike TCP sockets, UDP is 'connectionless', meaning that each message is sent as a unit to recipient. Also, unlike TCP, delivery is not guaranteed, so this should be used only in situations where losing messages is not a problem. This module is fashioned after the Node dgram module. The main difference is that this module provides support for send and receive data types so that a user of the module can just specify those types and not have to parse the received data. A simple example that listens for messages on port 8084 and prints out any that arrive: var UDPSocket = require('@accessors-modules/udp-socket'); var socket = UDPSocket.createSocket(); socket.on('message', function(message) { print('Received from web socket: ' + message); }); socket.bind(8084); Functions
Socket ClassAn instance of this class, created with new, is a socket client that can send or receive messages to a server at the host and port to the constructor. The constructor takes one argument:
The Socket object is an event emitter that emits the following events:
To receive messages, call bind() on a Socket object. To send messages, call send(). A Socket object has the following functions:
See https://ptolemy.berkeley.edu/accessors/wiki/Modules/UDPSocket for further information. |