![]() |
VOOZH | about |
The dgram.createSocket() method is an inbuilt application programming interface within dgram module which is used to create the dgram.socket object.
Syntax:
const dgram.createSocket(options[, callback])
Parameters: This method takes the following parameter:
Return Value: This method returns the object of dgram.socket.
Example 1: In this example, we will see the use of dgram.createSocket() Method
Filename: index.js
Output:
12345 UDP String: Hello
Example 2: In this example, we will see the use of dgram.createSocket() Method
Filename: index.js
Output:
server listening 0.0.0.0:1234 1234567 server is created UDP String: Hello
Run the index.js file using the following command:
node index.js
Reference: https://nodejs.org/dist/latest-v12.x/docs/api/dgram.html#dgram_dgram_createsocket_options_callback