🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.java.help
Article #182

Re: Help in Reading the serial or parallel port

#182
From: Ben Z. Tels
Date: Tue, 13 Jun 2000 00:00
55 lines
2697 bytes
> I have a c++ program that reads a "1" when someone enters a room. I need
> to be able to send a message through internet to a client telling that
> someone enters and when that happend, the client must download a file
> from the server and store it in its hard disk.
> So the question is:
> 1) How can i send messages from C++ thru internet,

That depends completely on tha platform you are compiling on and the library
you are using to add internet connectivity to C++. And probably also on the
compiler you are using.

In other words, god only knows and even he probably can't get it to work
right.

> or even better, how
> can I read the parallel port in java and send a mesage when something
> happend?

Two options:

1. You can use JNI to connect Java to native code that does the reading for
you.
2. You can use the COMM 2.0 API; it's not exactly finished yet (early-access
code), but it will allow Java to connect to the serial and parallel ports in
a platform-independent way.

As for sending the message, you use a Socket and its streams and probably
also the Observer-Subject pattern to glue the reading of a 1 on the port to
the sending of the message.

> 2)How can i Sava a remote file from a defined URL with different names
> each time, whe some kind of message is received?

You instantiate a java.net.URL to point to your defined URL.
Then ask that URL for a stream to read data from (possibly chain it to a
BufferedInputStream).
Then read the file from that stream, into some form of memory.
And finally dump it through a FileOutputStream onto the harddisk, giving it
whatever name you like.

> My Java skills are  obviously none, so please Help me.
> Should I use CGI instead?

What good would that do?


--
Ben Z. Tels
optimusb@stack.nl
http://www.stack.nl/~optimusb/
UIN:2474460

"The Earth is the cradle of the mind, but one cannot stay in the cradle
forever."
                                        --Tsiolkovsky
Technical Details
Message-ID: <8i5j4g$32f$1@news.IAEhv.nl>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <39457BE6.23058244@cec.uchile.cl>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb3cb,b97f5e0425db66b0
X-Google-Attributes: gidfb3cb,public
X-Google-Thread: 1116f3,b97f5e0425db66b0
X-Google-Attributes: gid1116f3,public
X-Google-Thread: 113ae9,b97f5e0425db66b0
X-Google-Attributes: gid113ae9,public
From: "Ben Z. Tels" <optimusb@stack.nl>
Subject: Re: Help in Reading the serial or parallel port
Date: 2000/06/13
Message-ID: <8i5j4g$32f$1@news.IAEhv.nl>
X-Deja-AN: 634011576
References: <39457BE6.23058244@cec.uchile.cl>
Organization: Internet Access Eindhoven, the Netherlands
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
Newsgroups: comp.lang.java.help,comp.lang.javascript,es.comp.lenguajes.java