[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OFF-TOPIC: HTML to send data out a certain port

On 10/03/2011 03:12 PM, Bob Proulx wrote:
Kent West wrote:
I don't have the Global Cache yet to play with, but I'm
trying to get a feel for how to do things before we start spending
money. The API documentation from their web site indicates it's a
matter of just sending the correct ASCII sequence out the web
server's TCP socket on Port 4998.
Sounds reasonable and likely.

You should try this from the command line to get a feel for it first.
Then after understanding it there it will be easier for you to write
this into the back-end of a web page.

I like the 'connect' command for this type of thing.  Others like 'nc'
(aka netcat).  For netcat you will need to choose between either the
traditional one or the new openbsd one.  You can install it with APT.

   # apt-get install connect-proxy netcat-openbsd

Then call it like this:

   $ connect hostname.example.com 4998

At that point you are talking to your network device.  You can send it
commands interactively and see the response.

   $ connect hostname.example.com 4998

I would tend to use an echo or a here-document.

   $ echo "get_NET,0:1" | connect hostname.example.com 4998


   $ connect hostname.example.com 4998<<EOF

Better yet, can anyone also provide me a means of testing if I'm
sending to that port without yet having the hardware in-hand? Like,
if I manage to send data to port 4998, how do I know I sent it and
what it looks like on the other side?
The above assumes that you have a real device.  But you don't yet.  So
how do you fake it?  You can use netcat to listen.  Open a second
terminal window and type in:

   $ nc -l -p 4998

That will listen on the same socket as your device would be
listening on port 4998.  Then connect to it from the first terminal.

   $ connect hostname.example.com 4998

Those two windows will be talking to each other.  If you send the
command get_NET,0:1 from one it will be received on the other.  You
can type a reply back and it will go back the other direction.

Play with that for a bit until you understand what is happening.  It
is simple but it will help you when it comes time to write your web

This is the sort of information I need. Thanks! But the man page for nc says -l and -p are not to be used together, and it doesn't work when I try to use them together. So I'm not sure how to listen to incoming data.

Kent West<*)))><
Praise Yah! \o/

Reply to: