From f9bfd19edecc3eb9665d692b65d40a0a838e94ef Mon Sep 17 00:00:00 2001 From: xl1034 Date: Sun, 27 Oct 2024 23:26:18 +0700 Subject: [PATCH] Initial commit --- data.txt | 15 +++++++++++++++ index.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 data.txt create mode 100644 index.js diff --git a/data.txt b/data.txt new file mode 100644 index 0000000..7205055 --- /dev/null +++ b/data.txt @@ -0,0 +1,15 @@ +SIZE 2.000,4.000 +GAP 0.120,0.000 +SPEED 4 +DENSITY 7 +DIRECTION 1,0 +REFERENCE 0,0 +OFFSET 0.000 +SHIFT 0 +SET TEAR OFF +SET PEEL OFF +SET PARTIAL_CUTTER OFF +SET CUTTER 1 +CLS +BITMAP 0,0,150,2400,1,??????????????????????????????????????????????????????????????????????????????????????pp8????????????????????????????????????????????????????????????????????~?~???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????pp8?????????????????????????????????????????????????????????????????????~?~????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????pp8????????????????????????????????????????????????????????????????????~?~???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????pp8?????????????????????????????????????????????????????????????????????~?~????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????pp8????????????????????????????????????????????????????????????????????~?~????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????pp8????????????????????????????????????????????????????????????????????~?~????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????pp8????????????????????????????????????????????????????????????????????~?~????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????pp8????????????????????????????????????????????????????????????????????~?~????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????pp8????????????????????????????????????????????????????????????????????~?~????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????pp8????????????????????????????????????????????????????????????????????~?~???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????pp8?????????????????????????????????????????????????????????????????????~?~?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? +PRINT 1,1 diff --git a/index.js b/index.js new file mode 100644 index 0000000..be85f70 --- /dev/null +++ b/index.js @@ -0,0 +1,31 @@ +const net = require('net'); +const fs = require('fs'); + +const PORT = 9100; +const FILE_PATH = 'data.txt'; + +const server = net.createServer((socket) => { + console.log('Client connected'); + + socket.on('data', (data) => { + fs.appendFile(FILE_PATH, data, (err) => { + if (err) { + console.error(err); + } else { + console.log('Data written to file'); + } + }); + }); + + socket.on('end', () => { + console.log('Client disconnected'); + }); + + socket.on('error', (err) => { + console.error(err); + }); +}); + +server.listen(PORT, () => { + console.log(`Server running on port ${PORT}`); +});