🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #1794

Re: Quick question about sockets.

#1794
From: Alex Colic
Date: Fri, 07 Sep 2001 14:04
50 lines
2773 bytes
Ok, got the book looking at the examples.

Question: the apps that are doing the listening are a bunch of web apps
jsp/servlets. Lets say I have 5 of them and they all need to listen on this
port. If I create a monitor class that uses a ServerSocket than I can only
have one of these web apps listening.

How about creating one monitor class that starts when the web server starts.
Then all my web apps register with this monitor class to receive commands.

1: should this monitor class be a servlet?
2: how can I get the monitor class to start when the server starts?
3: how can classes in other web applicatons register themselves with this
servlet?

Thanks for any help.

Alex


"Joi Ellis [TeamB]" <joi@aravox.com> wrote in message
news:3b98cc80_1@dnews...
> Alex Colic <alex.colic@pop-ware.com> wrote:
> > Hi,
>
> > Ok I am obviously doing something wrong. I picked the ServerSocket
class
> > because I do not know what host is going to send me commands, just the
port.
>
> > Any idea how I can have more than one class just listen to the same port
for
> > commands?
>
> You can't.  The general idea for this is to have a class that does nothing
> but listen, then spawns threads to handle incoming connections.  Once the
> child threads have their sockets, the parent goes back to listening for
> more connections.
>
> This is pretty much how inetd works on *nix.  There are examples of doing
this
> in Java in the O'Reilly 'Java Networking' book, among others.
>
> --
> Joi Ellis (TeamB)               http://www.teamb.com/
> No direct email, please.
> For best results, post on news server newsgroups.borland.com!
> Newsgroup Guidelines: http://www.borland.com/newsgroups/guide.html
> Only posts which violate the rules in guide.html are subject to
cancelation.
Technical Details
Message-ID: <3b98d3f5_1@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!193.251.151.101!opentransit.net!newsfeed.icl.net!skynet.be!skynet.be!newsfeed1.uni2.dk!newssuck.uni2.dk!dnews
References: <3b97d61e_1@dnews> <3b9859d6$1_2@dnews> <3b98be46$1_2@dnews> <3b98cc80_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,75eb349919d2da57
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2001-09-07 07:12:42 PST
From: "Alex Colic" <alex.colic@pop-ware.com>
Newsgroups: borland.public.jbuilder.java.api
References: <3b97d61e_1@dnews>  <3b9859d6$1_2@dnews> <3b98be46$1_2@dnews> <3b98cc80_1@dnews>
Subject: Re: Quick question about sockets.
Date: Fri, 7 Sep 2001 10:04:34 -0400
Lines: 52
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
NNTP-Posting-Host: 24.150.29.218
Message-ID: <3b98d3f5_1@dnews>
X-Trace: dnews 999871477 24.150.29.218 (7 Sep 2001 07:04:37 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!news.tele.dk!small.news.tele.dk!193.251.151.101!opentransit.net!newsfeed.icl.net!skynet.be!skynet.be!newsfeed1.uni2.dk!newssuck.uni2.dk!dnews