![]() |
VOOZH | about |
The socket.send() method is an inbuilt application programming interface of class Socket within dgram module which is used to send the message from one socket to another.
Syntax:
socket.send(msg[, offset, length][, port][, address][, callback])
Parameters: This method takes the following parameter:
Return Value: This method does not return any value.
Example 1: In this example, we will see the use of socket.send() Method
Filename: index.js
Output:
[ 'message' ] UDP String: Hello
Example 2: In this example, we will see the use of a socket.send() Method
Filename: index.js
Output:
server listening 0.0.0.0:1234 [ 'message', 'listening' ] message sent UDP String: Hello
Run the index.js file using the following command:
node index.js