Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added robin_stringer/.DS_Store
Binary file not shown.
File renamed without changes.
27 changes: 27 additions & 0 deletions robin_stringer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "robin_stringer",
"version": "1.0.0",
"description": "Create a TCP Server ======================== To complete this assignment: * fork this repository (the sub module for this specific assignment) * clone down your fork * place all of your work in a folder that is your full name, use `_`s instead of spaces * push back up to your fork * create a pull request back to the original repo * submit a link to the PR in canvas",
"main": "gulpfile.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/rastringer/create_a_tcp_server.git"
},
"author": "ra1stringer@gmail.com",
"license": "MIT",
"bugs": {
"url": "https://github.com/rastringer/create_a_tcp_server/issues"
},
"homepage": "https://github.com/rastringer/create_a_tcp_server#readme",
"devDependencies": {
"chai": "^3.4.1",
"mocha": "^2.3.3"
}
}
28 changes: 28 additions & 0 deletions robin_stringer/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Write a simple tcp logging server. This server should receive tcp requests and save the request into a file.
'use strict';
var fs = require('fs');
var net = require('net');
var port = 3000;

var server = net.createServer(function(socket) {
socket.on('data', function(data) {
console.log(data.toString());

fs.writeFile((Date.now().toString()), data, function(err) {
if(err) throw err;
console.log('Saved!');
});
});

socket.on('end', function() {
console.log('socket closed');
});

server.close(function() {
console.log('Server closed');
});
});

server.listen('3000', function() {
console.log('server up on port ' + port);
});
10 changes: 10 additions & 0 deletions robin_stringer/test/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

var chai = require('chai');
var net = require('net');
var fs = require('fs');

describe('tcp server responding', function() {
it('should have status 200', function() {
});
});