hrz_sv / 01.Server / Client.js @ 22
이력 | 보기 | 이력해설 | 다운로드 (630 Bytes)
| 1 | 22 | HKM | var PORT = 11000 ; |
|---|---|---|---|
| 2 | var dgram = require('dgram'); |
||
| 3 | var client = dgram.createSocket('udp4'); |
||
| 4 | |||
| 5 | client.on('listening', function () { |
||
| 6 | var address = client.address();
|
||
| 7 | console.log('UDP Client listening on ' + address.address + ":" + address.port); |
||
| 8 | client.setBroadcast(true)
|
||
| 9 | client.setMulticastTTL(128);
|
||
| 10 | client.addMembership('224.1.1.1');
|
||
| 11 | }); |
||
| 12 | |||
| 13 | client.on('message', function (message, remote) { |
||
| 14 | console.log('A: Epic Command Received. Preparing Relay.');
|
||
| 15 | console.log('B: From: ' + remote.address + ':' + remote.port +' - ' + message); |
||
| 16 | }); |
||
| 17 | |||
| 18 | client.bind(PORT); |