Results 1 to 14 of 14
Thread: events on a server socket
- 07-31-2010, 11:01 AM #1
Senior Member
- Join Date
- Jan 2010
- Posts
- 138
- Rep Power
- 0
- 07-31-2010, 11:26 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
Nope, when a ServerSocket isn't in an accepting state it simply doesn't 'listen' for connection requests. There is a queue for clients waiting for a connection (see the backLog parameter for the constructor) but that's all, there is no event such as 'client waiting to be connected'.
kind regards,
Jos
- 07-31-2010, 02:29 PM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 07-31-2010, 02:51 PM #4
Senior Member
- Join Date
- Jan 2010
- Posts
- 138
- Rep Power
- 0
is there an event handler for a socket which will listen for the connection status?
- 07-31-2010, 03:56 PM #5
What do you want to use this for?
What would you do if there was a client connect coming to a ServerSocket?
- 07-31-2010, 04:07 PM #6
Senior Member
- Join Date
- Jan 2010
- Posts
- 138
- Rep Power
- 0
Q: What do you want to use this for?
A: monitoring multiple client connection
Q:What would you do if there was a client connect coming to a ServerSocket?
A: to check max. concurrent client connection..
any event-driven can I use to monitor it? or do you have any idea?
- 08-01-2010, 04:42 AM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
What ever you want to do, you've to accept the client connection. Then before put into your connection pool, validate accordingly you want. Based on the validation you can response to the client.
- 08-01-2010, 01:37 PM #8
Senior Member
- Join Date
- Jan 2010
- Posts
- 138
- Rep Power
- 0
what do you mean by connection pool?
is that something like connection id that I can use to do something to the connection? .. could you please give me a simple example?
- 08-01-2010, 02:52 PM #9
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
Why not extend (or encapsulate) the ServerSocket class in your own class? It can poop up its functionality by adding a PropertyChangeSupport class to it so you can notify any listener when you have accepted a new connection. The API documentation for those classes is your friend.
kind regards,
Jos
- 08-01-2010, 03:06 PM #10
Senior Member
- Join Date
- Jan 2010
- Posts
- 138
- Rep Power
- 0
extend (or encapsulate) the ServerSocket class in my own class?
as a newbie I am more confusing with this :confused:
could you please give me a simple example for this? .. (just for a clue :))
- 08-01-2010, 03:46 PM #11
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
Not 'your class', write another class for that purpose that can accept a client socket (just like a ServerSocket does) but it also can notify any listener for that fact. A ServerSocket can be a (private) member of that class and a PropertyChangeListener can handle the event propagation. Reading the API documentation can do wonders; there will be no need to write much code for it.
kind regards,
Jos
- 08-01-2010, 05:58 PM #12
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 08-02-2010, 03:18 PM #13
Senior Member
- Join Date
- Jan 2010
- Posts
- 138
- Rep Power
- 0
Thanks for the clue!
- 08-03-2010, 08:24 AM #14
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Similar Threads
-
design & generics for socket server
By gilme in forum New To JavaReplies: 1Last Post: 06-18-2010, 04:24 AM -
typed events vs untyped events.
By Drun in forum SWT / JFaceReplies: 0Last Post: 11-23-2009, 12:22 PM -
Server Socket
By Moncleared in forum New To JavaReplies: 1Last Post: 09-05-2009, 06:08 AM -
(Server)Socket application deploying
By mdinant in forum NetworkingReplies: 0Last Post: 04-09-2008, 05:10 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks