cpanon Posted April 7, 2007 Share Posted April 7, 2007 Hello I have an odd need, that hopefully one of you great gurus can help, grin. I need to a process on the server listening for a particular port. Grab the response and forward it on to a servlet. I know enough to be dangerous to ass-ume. I have done a little php. I need help on these points: 1. How do I start a process/script for just listening on the server and loop it forever? 2. How do I format the response and forward it to a servlet? tia. Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 7, 2007 Share Posted April 7, 2007 well i can help you on the loop forever part since i did that mistake once in a mail script and ended up deleting over 4000 emails =) haha <?php $i = 0; while ($i != 1) { ...command... } ?> Quote Link to comment Share on other sites More sharing options...
cpanon Posted April 7, 2007 Author Share Posted April 7, 2007 hi thanks pieces if fine. we are all aggregators now Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted April 7, 2007 Share Posted April 7, 2007 hehe i have no idea what "aggregators" means Quote Link to comment Share on other sites More sharing options...
redking Posted April 7, 2007 Share Posted April 7, 2007 basically what he said, except it should be a cron job, that way it will be forked and won't consume all of your processor speed. and to listen for a port you are going to need to use the php socket functions, I suppose you know somthing about sockets and the like... http://www.php.net/manual/en/ref.sockets.php heres some reference for php sockets I'm not sure exactly what you are trying to do, so I really cant give you any example source. loop forever 1 . have it listen for an incoming connection 2 . If you get an incoming connection create your connection to the servlet and send whatever you need to send. I hope my incoherent ramblings help Quote Link to comment Share on other sites More sharing options...
cpanon Posted April 7, 2007 Author Share Posted April 7, 2007 Hi Thanks. However I will be running this on Apache 2 on win32 and I dont think I can get cgywin up. Is there an efficient way of doing rather than just posting the page and letting it run? So it sounds like I will need to use sockets and cURL? My project is "in the lab" state right now. My competence is with servlets/struts. I am talking to a cc processor at the api level. I have allot of code already in servlet and I want to reuse it. So I am thinking about pre-processing the data with an action, sending it to the processor. This is next is where the php comes in. Have a php script running on one of the virtual host in my apache setup just listening for the response, capture the response and forward it to my post-processing servlet, release and repeat. Of course in theory it will work fine, now how to do it in reality. Any help of the php piece would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
per1os Posted April 7, 2007 Share Posted April 7, 2007 link=topic=135007.msg568771#msg568771 date=1175976896] hehe i have no idea what "aggregators" means Definitions of aggregators on the Web: * Aggregators, such as NewsGator and AmphetaDesk , allow users to subscribe to feeds from sources as diverse as the BBC, Sci-Fi Today, Slashdot and thousands of bloggers across the world. The services work by checking an Internet address at a regular interval, usually once an hour, to see if new content has been added. ... lol doesn't really fit huh? I know aggregate is like a total or sum of objects in a sense or a group. That fits better =) Quote Link to comment Share on other sites More sharing options...
cpanon Posted April 7, 2007 Author Share Posted April 7, 2007 Hi I was using it in the context of developers. No one is writing LALR parsers anymore. And it is consistent with the high level description you provided. Hey we are all just rearranging electrons at the expense of energy which of course is.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.