Thread View: comp.lang.java.help
3 messages
3 total messages
Started by Jaime Heiss
Mon, 12 Jun 2000 00:00
Help in Reading the serial or parallel port
Author: Jaime Heiss
Date: Mon, 12 Jun 2000 00:00
Date: Mon, 12 Jun 2000 00:00
19 lines
1750 bytes
1750 bytes
Hello. I need assistance in order to make the following application: 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, or even better, how can I read the parallel port in java and send a mesage when something happend? 2)How can i Sava a remote file from a defined URL with different names each time, whe some kind of message is received? My Java skills are obviously none, so please Help me. Should I use CGI instead? Thanks in advance, Jaime Heiss
Re: Help in Reading the serial or parallel port
Author: Ben Z. Tels
Date: Tue, 13 Jun 2000 00:00
Date: Tue, 13 Jun 2000 00:00
55 lines
2697 bytes
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
Re: Help in Reading the serial or parallel port
Author: Moises Garcia Cogolludo
Date: Tue, 13 Jun 2000 00:00
Date: Tue, 13 Jun 2000 00:00
40 lines
2459 bytes
2459 bytes
Jaime Heiss wrote: > Hello. > I need assistance in order to make the following application: > > 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, or even better, how > can I read the parallel port in java and send a mesage when something > happend? You can send messages thru internet via Socket's In Java you can't access the serial or pararell ports, but there is an API, the Java Communications API which can do it. You can get it at java.sun.com in the Products and API's section. > > 2)How can i Sava a remote file from a defined URL with different names > each time, whe some kind of message is received? O.K. this question depends on what do you want to do, you can make something to create new names and save the file with de new name created, or you can add a number to the end of the file name (not the extension) that you will increment after you save the file. > > > My Java skills are obviously none, so please Help me. > Should I use CGI instead? > > Thanks in advance, > Jaime Heiss Sorry about my English, I'm Spanish.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads