Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Voting
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dennis Willers
Voting
Commits
28440615
Commit
28440615
authored
Aug 19, 2021
by
Dennis Willers
🏀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test if Host listenes makes a different
parent
26a7fb4a
Pipeline
#413
passed with stages
in 2 minutes and 44 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
socket.js
socket.js
+10
-7
No files found.
socket.js
View file @
28440615
...
@@ -129,8 +129,10 @@ server.on('listening',function(){
...
@@ -129,8 +129,10 @@ server.on('listening',function(){
server
.
maxConnections
=
500
;
server
.
maxConnections
=
500
;
var
HOST
=
'
0.0.0.0
'
;
// bind to all interfaces, not just loopback
var
PORT
=
3000
;
//static port allocation
//static port allocation
server
.
listen
(
3000
);
server
.
listen
(
PORT
,
HOST
);
// for dyanmic port allocation
// for dyanmic port allocation
...
@@ -162,9 +164,10 @@ setTimeout(function(){
...
@@ -162,9 +164,10 @@ setTimeout(function(){
//---------------------client----------------------
//---------------------client----------------------
// creating a custom socket client and connecting it....
// creating a custom socket client and connecting it....
var
client
=
new
net
.
Socket
();
/*
var client = new net.Socket();
client.connect({
client.connect({
port
:
3000
host: 'm.willers.digital',
port: 80
});
});
client.on('connect',function(){
client.on('connect',function(){
...
@@ -194,7 +197,7 @@ client.on('data',function(data){
...
@@ -194,7 +197,7 @@ client.on('data',function(data){
/*setTimeout(function(){
/*setTimeout(function(){
client.end('Bye bye server');
client.end('Bye bye server');
},5000);
},5000);
*/
//NOTE:--> all the events of the socket are applicable here..in client...
//NOTE:--> all the events of the socket are applicable here..in client...
...
@@ -204,8 +207,8 @@ client.on('data',function(data){
...
@@ -204,8 +207,8 @@ client.on('data',function(data){
// u can also => write the below code in seperate js file
// u can also => write the below code in seperate js file
// open new node instance => and run it...
// open new node instance => and run it...
const clients = net.connect({port: 3000}, () => {
/*
const clients = net.connect({port: 3000}, () => {
// 'connect'
listener
// 'connect'
3201
console.log('connected to server!');
console.log('connected to server!');
clients.write('world!\r\n');
clients.write('world!\r\n');
});
});
...
@@ -216,7 +219,7 @@ clients.on('data', (data) => {
...
@@ -216,7 +219,7 @@ clients.on('data', (data) => {
clients.on('end', () => {
clients.on('end', () => {
console.log('disconnected from server');
console.log('disconnected from server');
});
});
*/
//
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment