0

Intro: Hello. So I started on a chat based social media app with Socket.io, but it seems like the client needs to open a localhost server to be able to communicate with the socket manager on my web API (node, express, socket.io).

Question Tree: Is it possible to make a nodejs server client side and execute a script with an html front end button so that the socket has a localhost to run tcp on to communicate to my web API? If so, how can I do this? If not, what are some alternatives to achieve the same results?

conclusion: Any help is appreciated, I am learning how to do this sort of development for school and I just want some clarity. Thank you!

  • Why not open a web socket connection from the JavaScript in your HTML page to your server? It’s unclear why you think you need a separate local server in addition… – deceze Jan 16 '21 at 15:45
  • I found out how to do this earlier, but I reached another barrier and that is getting the name client sided to use in server sided javascript served to the user's dom –  Jan 17 '21 at 03:34

1 Answers1

0

It is possible if you are on linux you have to make a bash script file that will run your app.js or index.js node file, for ex

node app.js

that will get executed when you press a button on page which again is easy if you use some server side language like php if you are interested here is the link for moreenter link description here

with just html its not possible easily its just too much of a task, just type that command in your terminal and you are good to go

rather you can make a script like bash in linux or bat in windows, that will open the server client side if you open that script file.

Mohak Gupta
  • 163
  • 1
  • 9
  • This will work but it's not user friendly having to download dependencies etc. –  Jan 17 '21 at 03:35