Re: UDP Server app
Martin and others, Thanks for the help. When I was running both the server and client off my local machine, I was getting a socketexception on the client - Address already in use: Cannot bind which makes sense, since they were both trying to bind to the same port. Once I deployed my UDPServer to a different machine, I was able send udp datagrams successfully and process them on the server running in Tomcat. Now I just need to figure out how to stop the component and close the socket. I have a while loop depending on a boolean which I'm changing, but when it's blocking on the datagramsocket.receive() it won't drop out of the loop. I probably need to start a thread and just end the thread. K --- Martin Gainty [EMAIL PROTECTED] wrote: Agreed.. To confirm that you are already connected to the specified ports I would encourage you to take a look at netstat -a which will display all used ports in which case you can then grep for the port to ascertain its 'in use' status To extend on that concept..Take for instance SunOne which is a J2EE App Server available from Sun (documentation which is available at http://docs-pdf.sun.com/819-1398/819-1398.pdf) and note that Sun One AppServer allows the specification of Port Range..so that if one port is used Sun One auto-fails over to the next port for that particular subsystem Also BEA supports Port Range scenario for the same reason You can write your own.. but if the AppServer you are using already supports Port Range why bother? Anyone else ? M - Original Message - From: KJ R [EMAIL PROTECTED] To: Tomcat Users List users@tomcat.apache.org Sent: Tuesday, December 27, 2005 5:22 PM Subject: RE: UDP Server app Yes I know JNDI itself is not a Tomcat feature, but their CONNECTION POOL implementation IS a feature I'm interested in. I'm not planning on writing my own connection pool, I like the way they've done it, as well as their price! Tomcat also offers advantages in ease of debugging, error handling, and integration with my development environment - Eclipse. Also as I've stated I'm much more familiar with Tomcat then standalone java apps, so sometimes you go with what you know. That being said, I was able to create a webpage to initiate the start() method on my class. It looks like it's probably working because when I tried to use my udp_client web app to test it, got a message saying the port was already in use and could not bind, so I'm getting close. Any other suggestions? --- Caldarale, Charles R [EMAIL PROTECTED] wrote: From: KJ R [mailto:[EMAIL PROTECTED] Subject: RE: UDP Server app The main reason to run under Tomcat for me would be when I update the database, I'd like to use a JNDI connection pool for my dataaccess class. JNDI is not a feature of Tomcat, it's a capability of the Java execution environment. Tomcat merely allows you to configure JNDI entries non-programmatically. You can accomplish the same thing more simply in a standalone app with command line parameters. You're still subverting the purpose of Tomcat: it's intended to handle web applications using HTTP in a request/response mode. Your app isn't anything like that - you have no need of a Servlet container or any other form of J2EE app server. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: UDP Server app
Good Morning K and Chuck I would suggest that when you call your Thread wait method you specify a wait period so your threads wont wait forever and possibly lock the process from responding e.g. wait(long timeout): waits for notification or until the timeout period has elapsed; timeout is measured in milliseconds check out http://java.sun.com/docs/books/tutorial/essential/threads/waitAndNotify.html Anyone else? Martin- - Original Message - From: KJ R [EMAIL PROTECTED] To: Tomcat Users List users@tomcat.apache.org Sent: Wednesday, December 28, 2005 8:57 AM Subject: Re: UDP Server app Martin and others, Thanks for the help. When I was running both the server and client off my local machine, I was getting a socketexception on the client - Address already in use: Cannot bind which makes sense, since they were both trying to bind to the same port. Once I deployed my UDPServer to a different machine, I was able send udp datagrams successfully and process them on the server running in Tomcat. Now I just need to figure out how to stop the component and close the socket. I have a while loop depending on a boolean which I'm changing, but when it's blocking on the datagramsocket.receive() it won't drop out of the loop. I probably need to start a thread and just end the thread. K --- Martin Gainty [EMAIL PROTECTED] wrote: Agreed.. To confirm that you are already connected to the specified ports I would encourage you to take a look at netstat -a which will display all used ports in which case you can then grep for the port to ascertain its 'in use' status To extend on that concept..Take for instance SunOne which is a J2EE App Server available from Sun (documentation which is available at http://docs-pdf.sun.com/819-1398/819-1398.pdf) and note that Sun One AppServer allows the specification of Port Range..so that if one port is used Sun One auto-fails over to the next port for that particular subsystem Also BEA supports Port Range scenario for the same reason You can write your own.. but if the AppServer you are using already supports Port Range why bother? Anyone else ? M - Original Message - From: KJ R [EMAIL PROTECTED] To: Tomcat Users List users@tomcat.apache.org Sent: Tuesday, December 27, 2005 5:22 PM Subject: RE: UDP Server app Yes I know JNDI itself is not a Tomcat feature, but their CONNECTION POOL implementation IS a feature I'm interested in. I'm not planning on writing my own connection pool, I like the way they've done it, as well as their price! Tomcat also offers advantages in ease of debugging, error handling, and integration with my development environment - Eclipse. Also as I've stated I'm much more familiar with Tomcat then standalone java apps, so sometimes you go with what you know. That being said, I was able to create a webpage to initiate the start() method on my class. It looks like it's probably working because when I tried to use my udp_client web app to test it, got a message saying the port was already in use and could not bind, so I'm getting close. Any other suggestions? --- Caldarale, Charles R [EMAIL PROTECTED] wrote: From: KJ R [mailto:[EMAIL PROTECTED] Subject: RE: UDP Server app The main reason to run under Tomcat for me would be when I update the database, I'd like to use a JNDI connection pool for my dataaccess class. JNDI is not a feature of Tomcat, it's a capability of the Java execution environment. Tomcat merely allows you to configure JNDI entries non-programmatically. You can accomplish the same thing more simply in a standalone app with command line parameters. You're still subverting the purpose of Tomcat: it's intended to handle web applications using HTTP in a request/response mode. Your app isn't anything like that - you have no need of a Servlet container or any other form of J2EE app server. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: UDP Server app
From: kjr_23 [mailto:[EMAIL PROTECTED] Subject: RE: UDP Server app 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. Is there a web interface for this app? If not, why are you trying to run it under Tomcat? From just the description above, it seems better suited as a standalone app - there's nothing you've described that would utilize the services Tomcat provides. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: UDP Server app
From: Pulkit Singhal [mailto:[EMAIL PROTECTED] Subject: Re: UDP Server app a) I think that since main() is a static method, it should run automagically when you deploy your app into webapps and start tomcat. At best, that's wishful thinking. Tomcat is not the same as java.exe (or the UNIX/Linux equivalent), and that's the only thing that calls main() automatically. Please read the Servlet spec. (Providing a static public main() API is sometimes useful as a means of testing a simple webapp outside of Tomcat.) In any event, there are standard APIs called at webapp initialization that can be used for this (again, read the spec), but that presumes that this application benefits in some way from being run under Tomcat. No evidence has been presented so far in this thread that such is the case. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: UDP Server app
Charles, The main reason to run under Tomcat for me would be when I update the database, I'd like to use a JNDI connection pool for my dataaccess class. I'm also much more familiar with Tomcat than a standalone java app, although I'm not committed to using it. Being able to port it over to another servlet container would be helpful also. Most of our clients will have Sybase's EA Server. I've changed my UDPServer class to implement start() stop() and run() methods. I'd like to have it be a service that starts when Tomcat does, but if not, I can access via a webpage and start/stop it. Thanks, Kevin --- Caldarale, Charles R [EMAIL PROTECTED] wrote: From: Pulkit Singhal [mailto:[EMAIL PROTECTED] Subject: Re: UDP Server app a) I think that since main() is a static method, it should run automagically when you deploy your app into webapps and start tomcat. At best, that's wishful thinking. Tomcat is not the same as java.exe (or the UNIX/Linux equivalent), and that's the only thing that calls main() automatically. Please read the Servlet spec. (Providing a static public main() API is sometimes useful as a means of testing a simple webapp outside of Tomcat.) In any event, there are standard APIs called at webapp initialization that can be used for this (again, read the spec), but that presumes that this application benefits in some way from being run under Tomcat. No evidence has been presented so far in this thread that such is the case. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: UDP Server app
Yes I know JNDI itself is not a Tomcat feature, but their CONNECTION POOL implementation IS a feature I'm interested in. I'm not planning on writing my own connection pool, I like the way they've done it, as well as their price! Tomcat also offers advantages in ease of debugging, error handling, and integration with my development environment - Eclipse. Also as I've stated I'm much more familiar with Tomcat then standalone java apps, so sometimes you go with what you know. That being said, I was able to create a webpage to initiate the start() method on my class. It looks like it's probably working because when I tried to use my udp_client web app to test it, got a message saying the port was already in use and could not bind, so I'm getting close. Any other suggestions? --- Caldarale, Charles R [EMAIL PROTECTED] wrote: From: KJ R [mailto:[EMAIL PROTECTED] Subject: RE: UDP Server app The main reason to run under Tomcat for me would be when I update the database, I'd like to use a JNDI connection pool for my dataaccess class. JNDI is not a feature of Tomcat, it's a capability of the Java execution environment. Tomcat merely allows you to configure JNDI entries non-programmatically. You can accomplish the same thing more simply in a standalone app with command line parameters. You're still subverting the purpose of Tomcat: it's intended to handle web applications using HTTP in a request/response mode. Your app isn't anything like that - you have no need of a Servlet container or any other form of J2EE app server. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: UDP Server app
From: KJ R [mailto:[EMAIL PROTECTED] Subject: RE: UDP Server app Yes I know JNDI itself is not a Tomcat feature, but their CONNECTION POOL implementation IS a feature I'm interested in. Take a look at the DBCP package from Jakarta Commons - it's what Tomcat uses: http://jakarta.apache.org/commons/dbcp/ Same price as Tomcat. The Commons Logging package will help in your debugging. It looks like it's probably working because when I tried to use my udp_client web app to test it, got a message saying the port was already in use and could not bind, Do a netstat -a to see if the port is in use. Platform-specific options on netstat can help you find out which process already has it if that's the case. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: UDP Server app
Agreed.. To confirm that you are already connected to the specified ports I would encourage you to take a look at netstat -a which will display all used ports in which case you can then grep for the port to ascertain its 'in use' status To extend on that concept..Take for instance SunOne which is a J2EE App Server available from Sun (documentation which is available at http://docs-pdf.sun.com/819-1398/819-1398.pdf) and note that Sun One AppServer allows the specification of Port Range..so that if one port is used Sun One auto-fails over to the next port for that particular subsystem Also BEA supports Port Range scenario for the same reason You can write your own.. but if the AppServer you are using already supports Port Range why bother? Anyone else ? M - Original Message - From: KJ R [EMAIL PROTECTED] To: Tomcat Users List users@tomcat.apache.org Sent: Tuesday, December 27, 2005 5:22 PM Subject: RE: UDP Server app Yes I know JNDI itself is not a Tomcat feature, but their CONNECTION POOL implementation IS a feature I'm interested in. I'm not planning on writing my own connection pool, I like the way they've done it, as well as their price! Tomcat also offers advantages in ease of debugging, error handling, and integration with my development environment - Eclipse. Also as I've stated I'm much more familiar with Tomcat then standalone java apps, so sometimes you go with what you know. That being said, I was able to create a webpage to initiate the start() method on my class. It looks like it's probably working because when I tried to use my udp_client web app to test it, got a message saying the port was already in use and could not bind, so I'm getting close. Any other suggestions? --- Caldarale, Charles R [EMAIL PROTECTED] wrote: From: KJ R [mailto:[EMAIL PROTECTED] Subject: RE: UDP Server app The main reason to run under Tomcat for me would be when I update the database, I'd like to use a JNDI connection pool for my dataaccess class. JNDI is not a feature of Tomcat, it's a capability of the Java execution environment. Tomcat merely allows you to configure JNDI entries non-programmatically. You can accomplish the same thing more simply in a standalone app with command line parameters. You're still subverting the purpose of Tomcat: it's intended to handle web applications using HTTP in a request/response mode. Your app isn't anything like that - you have no need of a Servlet container or any other form of J2EE app server. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: UDP Server app
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:[EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]