Hi, I'm currently using node & socket.io as a proxy for accessing to an old legacy app running on sockets.
It is in very very early state but it's working, take it as a proof of concept, not as a ruggedized app (it doesn't auto reconnect etc) socket io + http server http://jsfiddle.net/cnKM7/ basic tcp server (for testing) http://jsfiddle.net/fHy8H/ basic client http://jsfiddle.net/gJDEh/1/ I removed some code and did not test after so it might be broken but it should be enough to understand how it works. On Thu, Mar 8, 2012 at 6:13 PM, Evan <[email protected]> wrote: > Ahh! I would suggest you think about the flow of your application this way > which might clear things up: > > > - User on website loads a page, something like > /changeImage.html?newImage=picture1.jpg > > - nodejs server receives request for /changeImage.html and parses the GET > string to find the var newImage = "picture1.jpg" > > - Before returning to the user (rendering the HTML response for > changeImage.html), your server (not your html) runs a method to pass the > TCP command to your sign ( sendSignMessage({image = picture1.jpg}, > callback) ). sendSignMessage would connect to the digital sign (or make > use of a previously initialized connection) per [[ > http://nodejs.org/api/net.html#net_net_connect_arguments ]] > > - sendSignMessage() waits until it receives a response from the sign and > passes that message on to the callback passed to it, which in turn should > finally render out (with that response included) to the user on the website. > > > There are a few reasons for this type of architecture: > > - While I haven't done much work with digital signs, I have interfaced > with a lot of lighting control hardware, and those devices have trouble > dealing with lots of connections. Having your server maintain one > connection which is a proxy for all of your web users is useful > > - It's really hard (and often times impossible) to get javascript in the > browser to connect to arbitrary ports > > - It's also really hard (even with websocckets) to have javascript in the > browser act as a raw TCP connection to send arbitrary messages to a server > that isn't the same as the webserver (cross domain problems) > > On Thursday, March 8, 2012 1:16:07 AM UTC-8, tomfish wrote: >> >> Yes I thought that Socket.IO would be a little overkill. I now know I >> need to use regular sockets. But I can't seem to get this working. >> I believe I need to make an html file that sends commands to my tcp >> server? There is now way I can make my index.html interact with my >> server. >> >> Kind regards, >> Tom >> >> >> On 8 mrt, 08:11, Evan <[email protected]> wrote: >> > Socket.io while awesome, might be a little overkill here. It sounds >> like >> > you just need to connect to a port on a remote machine and sent some >> > commands. You can start up your connection like this >> > [[http://nodejs.org/api/net.**html#net_net_connect_arguments<http://nodejs.org/api/net.html#net_net_connect_arguments> >> **]] and then use >> > the client.write() method to send your string to the remote server. >> > >> > >> > >> > >> > >> > >> > >> > On Wednesday, March 7, 2012 5:54:43 AM UTC-8, tomfish wrote: >> > >> > > Hello, >> > >> > > I would like to send a command from a (local) website to a computer >> in the >> > > same network on a specific port. This port is in use by digital >> signage >> > > software. When the software receives this command, it changes the >> image. >> > > Can anyone help me with this? node.js and socket.IO are already >> installed, >> > > but I can't seem to find the right coding. >> > >> > > Thanks in advance, >> > >> > > Tom > > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
