Skip to content

Aliza tcp#8

Open
aliza89p wants to merge 6 commits into
sea-401d5-javascript:masterfrom
aliza89p:aliza-tcp
Open

Aliza tcp#8
aliza89p wants to merge 6 commits into
sea-401d5-javascript:masterfrom
aliza89p:aliza-tcp

Conversation

@aliza89p
Copy link
Copy Markdown

No description provided.

Comment thread aliza/tcp_server.js
const clients = [];

module.exports = exports = net.createServer((socket) => {
socket.name = socket.remotePort;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you add your own property to an instance you could run into a problem if the instance already has a property using that name. You could check docs, use a test in code (!socket.name) to be sure its not used, or assign a more app specific name like myapp_name. In this code you probably don't need to save it because you're using the value of a property that already exists. Wherever you're test or outputting socket.name, you could just use socket.remotePort. If you wanted to maintain a really app specific name, your sockets array could contain an array of objects, each of which holding the socket and the unique name like sockets = [{socket: , name:"Fred"}];. That all said, your stretch to supply a user id works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants