You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by kjr_23 <kj...@yahoo.com> on 2005/12/26 19:25:09 UTC

UDP Server app

I'm developing an application that will monitor a port on Tomcat 5.5.x and
receive udp datagrams.  I've got the class coded, but not sure if I've done
it correctly.  I created a class with a main() method that runs the code to
read from whatever port I specify.  Do I need to configure Tomcat to open
this port or listen on the port?  Should I inherit my server class from
thread, so it can be multithreaded?  How do I know my application is
running?  I usually just develop classes/applications that are initiated by
JSP pages.

Thanks,
K



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: UDP Server app

Posted by Pulkit Singhal <pu...@gmail.com>.
Hello,

First off: what you are attempting to do sounds really exciting.

Secondly...a few coments:

1) "I guess I can monitor the port without Tomcat needing to be configured
differently."
- In my experience, such statements can hurt you, don't guess...be sure. You
should (if you haven't already) try out the suggestions I gave you earlier
under option # (3) about "how to make sure that the app is up and running."
- What I said under (3) are just my thoughts and beliefs and I might be
wrong in which case you can post back saying: "Hey, wtf? U lied! This don't
work!" And in turn get a response from someone saying "well here's how you
configure Tomcat for it"
- Oh by the way...do let us know if it actually does work :)

2) I think you can start a loop in your main() that sits tight and listens
OR some other kind of observer that can be awoken once a message comes in!
However you choose to do this, you can then have worker threads spawned off
that go about doing whatever processing is required on/by the messages that
came in. That way you might be able to crunch a lot more. This is just what
I think, I am sure that if you wait a while you'll get a lot more/brighter
suggestions.

Cheers,
- Pulkit

On 12/26/05, kjr_23 <kj...@yahoo.com> wrote:
>
> Pulkit,
> This will be a brand new application.  We will be tracking a fleet of
> about
> 300 - 400 vehicles with modems in them which send out udp data.  We will
> configure them to send to a port of our choosing.  I am planning to host a
> java app on Tomcat to read this data, parse it and write to a
> database.  It
> sounds like your question 3 below is correct.  I just want to get it
> working, and my app happens to be deployed on Tomcat.  I guess I can
> monitor
> the port without Tomcat needing to be configured differently.  That being
> said, do you think my app with the main() method is the way to go, or
> should
> I extend thread and make it threaded with a run() method?  Anyone see any
> design flaws or opportunity for improvement?  As I said, most of my
> experience thus far has been writing web applications that are called from
> JSP's, so this is all new to me.
>
> Thanks,
> K
>
> -----Original Message-----
> From: Pulkit Singhal [mailto:pulkitsinghal@gmail.com]
> Sent: Monday, December 26, 2005 2:27 PM
> To: Tomcat Users List
> Subject: Re: UDP Server app
>
>
> Hi,
>
> A few questions to help clarify what you want:
>
> 1) Is this UDP port actually being used by your instance of Tomcat for
> implementing some functionality and you simply want to listen on the port
> without interfering with the actions that take place? (kind of like a wire
> tap)
> --> If you are indeed trying to "monitor a port on Tomcat" then I take it
> that Tomcat already makes use of that port of somehow. In which case, you
> should really have no need to open anything or configure Tomcat in any
> way,
> shape or form.
>
> 2) Are you looking to add-to Tomcat's present functionality on this UDP
> port
> or extend it with
> your code?
> --> I lack ideas on this one.
>
> 3) This really has nothing to do with Tomcat in the sense that you just
> want
> to listen on a UDP port and your app just happens to be deployed on Tomcat
> and you just want the damned thing to work?
> --> I think that if its simply an app that you deployed on Tomcat that
> will
> listen on any given UDP port then Tomcat has no business constraining you.
> But ofcourse this can be confirmed :)
>
> If it was me...here's how I would go about confirming:
> a) I think that since main() is a static method, it should run
> automagically
> when you deploy your app into webapps and start tomcat.
> b) You can confirm this by writing a fake webapp (real quick) where the
> main
> method contains print_out statements to your catalina.log
> c) If you see these log statements in catalina.log or wherever else you
> tried to output them to then your code in main() should have run.
> d) Now, put similar print statements in your real webapp's main() method
> inside the try and catch block so that you know if you are listening or
> failing.
> e) You can also write a test class that prints an UDP message on the port
> that you are either hard-coded to listen to or maybe have a configuration
> file for. In turn, have your listening webapp print any messages it
> captures. Then looking at the file (stdout or catalina.out) where you
> printed the message...you should have a good feel for where you stand.
>
> Cheers,
> - Pulkit
>
> On 12/26/05, kjr_23 <kj...@yahoo.com> wrote:
> >
> > I'm developing an application that will monitor a port on Tomcat 5.5.xand
> > receive udp datagrams.  I've got the class coded, but not sure if I've
> > done
> > it correctly.  I created a class with a main() method that runs the code
> > to
> > read from whatever port I specify.  Do I need to configure Tomcat to
> open
> > this port or listen on the port?  Should I inherit my server class from
> > thread, so it can be multithreaded?  How do I know my application is
> > running?  I usually just develop classes/applications that are initiated
> > by
> > JSP pages.
> >
> > Thanks,
> > K
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

RE: UDP Server app

Posted by kjr_23 <kj...@yahoo.com>.
Pulkit,
 This will be a brand new application.  We will be tracking a fleet of about
300 - 400 vehicles with modems in them which send out udp data.  We will
configure them to send to a port of our choosing.  I am planning to host a
java app on Tomcat to read this data, parse it and write to a database.  It
sounds like your question 3 below is correct.  I just want to get it
working, and my app happens to be deployed on Tomcat.  I guess I can monitor
the port without Tomcat needing to be configured differently.  That being
said, do you think my app with the main() method is the way to go, or should
I extend thread and make it threaded with a run() method?  Anyone see any
design flaws or opportunity for improvement?  As I said, most of my
experience thus far has been writing web applications that are called from
JSP's, so this is all new to me.

Thanks,
K

-----Original Message-----
From: Pulkit Singhal [mailto:pulkitsinghal@gmail.com]
Sent: Monday, December 26, 2005 2:27 PM
To: Tomcat Users List
Subject: Re: UDP Server app


Hi,

A few questions to help clarify what you want:

1) Is this UDP port actually being used by your instance of Tomcat for
implementing some functionality and you simply want to listen on the port
without interfering with the actions that take place? (kind of like a wire
tap)
--> If you are indeed trying to "monitor a port on Tomcat" then I take it
that Tomcat already makes use of that port of somehow. In which case, you
should really have no need to open anything or configure Tomcat in any way,
shape or form.

2) Are you looking to add-to Tomcat's present functionality on this UDP port
or extend it with
your code?
--> I lack ideas on this one.

3) This really has nothing to do with Tomcat in the sense that you just want
to listen on a UDP port and your app just happens to be deployed on Tomcat
and you just want the damned thing to work?
--> I think that if its simply an app that you deployed on Tomcat that will
listen on any given UDP port then Tomcat has no business constraining you.
But ofcourse this can be confirmed :)

If it was me...here's how I would go about confirming:
a) I think that since main() is a static method, it should run automagically
when you deploy your app into webapps and start tomcat.
b) You can confirm this by writing a fake webapp (real quick) where the main
method contains print_out statements to your catalina.log
c) If you see these log statements in catalina.log or wherever else you
tried to output them to then your code in main() should have run.
d) Now, put similar print statements in your real webapp's main() method
inside the try and catch block so that you know if you are listening or
failing.
e) You can also write a test class that prints an UDP message on the port
that you are either hard-coded to listen to or maybe have a configuration
file for. In turn, have your listening webapp print any messages it
captures. Then looking at the file (stdout or catalina.out) where you
printed the message...you should have a good feel for where you stand.

Cheers,
- Pulkit

On 12/26/05, kjr_23 <kj...@yahoo.com> wrote:
>
> I'm developing an application that will monitor a port on Tomcat 5.5.x and
> receive udp datagrams.  I've got the class coded, but not sure if I've
> done
> it correctly.  I created a class with a main() method that runs the code
> to
> read from whatever port I specify.  Do I need to configure Tomcat to open
> this port or listen on the port?  Should I inherit my server class from
> thread, so it can be multithreaded?  How do I know my application is
> running?  I usually just develop classes/applications that are initiated
> by
> JSP pages.
>
> Thanks,
> K
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: UDP Server app

Posted by Pulkit Singhal <pu...@gmail.com>.
Hi,

A few questions to help clarify what you want:

1) Is this UDP port actually being used by your instance of Tomcat for
implementing some functionality and you simply want to listen on the port
without interfering with the actions that take place? (kind of like a wire
tap)
--> If you are indeed trying to "monitor a port on Tomcat" then I take it
that Tomcat already makes use of that port of somehow. In which case, you
should really have no need to open anything or configure Tomcat in any way,
shape or form.

2) Are you looking to add-to Tomcat's present functionality on this UDP port
or extend it with
your code?
--> I lack ideas on this one.

3) This really has nothing to do with Tomcat in the sense that you just want
to listen on a UDP port and your app just happens to be deployed on Tomcat
and you just want the damned thing to work?
--> I think that if its simply an app that you deployed on Tomcat that will
listen on any given UDP port then Tomcat has no business constraining you.
But ofcourse this can be confirmed :)

If it was me...here's how I would go about confirming:
a) I think that since main() is a static method, it should run automagically
when you deploy your app into webapps and start tomcat.
b) You can confirm this by writing a fake webapp (real quick) where the main
method contains print_out statements to your catalina.log
c) If you see these log statements in catalina.log or wherever else you
tried to output them to then your code in main() should have run.
d) Now, put similar print statements in your real webapp's main() method
inside the try and catch block so that you know if you are listening or
failing.
e) You can also write a test class that prints an UDP message on the port
that you are either hard-coded to listen to or maybe have a configuration
file for. In turn, have your listening webapp print any messages it
captures. Then looking at the file (stdout or catalina.out) where you
printed the message...you should have a good feel for where you stand.

Cheers,
- Pulkit

On 12/26/05, kjr_23 <kj...@yahoo.com> wrote:
>
> I'm developing an application that will monitor a port on Tomcat 5.5.x and
> receive udp datagrams.  I've got the class coded, but not sure if I've
> done
> it correctly.  I created a class with a main() method that runs the code
> to
> read from whatever port I specify.  Do I need to configure Tomcat to open
> this port or listen on the port?  Should I inherit my server class from
> thread, so it can be multithreaded?  How do I know my application is
> running?  I usually just develop classes/applications that are initiated
> by
> JSP pages.
>
> Thanks,
> K
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>