{"size": 610, "ext": "js", "max_stars_repo_path": "src/a-udp-server.js", "max_stars_repo_name": "MahdiTa97/simple-triple-udp-tcp-connection", "max_stars_repo_stars_event_min_datetime": "2021-12-18T05:52:00.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-18T05:52:00.000Z", "max_issues_repo_path": "src/a-udp-server.js", "max_issues_repo_name": "MahdiTa97/simple-triple-udp-tcp-connection", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/a-udp-server.js", "max_forks_repo_name": "MahdiTa97/simple-triple-udp-tcp-connection", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 20.3333333333, "max_line_length": 58, "alphanum_fraction": 0.6016393443}
var dgram = require("dgram");

var PORT = 4444;

var server = dgram.createSocket("udp4");

server.on("listening", function () {
  var address = server.address();
  console.log("UDP SERVER LISTENING ON: " + address.port);
});

server.on("message", function (message, remote) {
  console.log("============");
  console.log("> Receive: " + message);
  var msgResponse = "Hi C";
  server.send(
    msgResponse,
    0,
    msgResponse.length,
    remote.port,
    remote.address,
    function (err, bytes) {
      if (err) throw err;
      console.log("< Send:  " + msgResponse);
    }
  );
});

server.bind(PORT);
