Thread View: comp.lang.java
1 messages
1 total messages
Started by Paul L. Mowatt
Tue, 16 Dec 1997 00:00
UNIX like select() for Java!
Author: Paul L. Mowatt
Date: Tue, 16 Dec 1997 00:00
Date: Tue, 16 Dec 1997 00:00
278 lines
11865 bytes
11865 bytes
This is a multi-part message in MIME format.
--------------B3EBE34E629232795E0F82F6
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
If you're looking for a way to multiplex input from Socket and
ServerSocket objects
simultaneously then check out:
http://www.mansatel.com/xware.net.Selector.html
The xware.net.Selector class provides an event-driven mechanism for
handling input from
multiple sockets. It is ideal for writing server like Java applets or
applications. It can be used
on both the client or server side of your sockets based interface.
Java's event delegation feature is used to deliver events. The delegate
simply implements a
ActionListener interface.
A link to a sample application is in the web page mentioned above.
For more details send e-mail to mailto:plm@bellatlantic.net
--------------B3EBE34E629232795E0F82F6
Content-Type: text/html; charset=us-ascii; name="xware.net.Selector.html"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="xware.net.Selector.html"
Content-Base: "http://www.mansatel.com/xware.net.Sele
ctor.html"
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="GENERATOR" CONTENT="Mozilla/4.04j2 [en] (X11; I; HP-UX B.10.20 9000/778) [Netscape]">
<TITLE> Class xware.net.Selector
</TITLE>
<!--NewPage-->
<!-- Generated by javadoc on Tue Dec 16 14:02:59 EST 1997 -->
</HEAD>
<BODY>
<H1>
Class xware.net.Selector</H1>
<PRE>java.lang.Object
|
+----xware.net.Selector</PRE>
<HR>
<DL>
<DT>
public class <B>Selector</B></DT>
<DT>
extends Object</DT>
</DL>
Selector - A class for multiplexing input from Socket and ServerSocket
instances
<P>
<HR><A NAME="index"></A>
<H2>
<IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/variable-index.gif" ALT="Variable Index" HEIGHT=38 WIDTH=207></H2>
<DL>
<DT>
<IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/blue-ball-small.gif" ALT="o" HEIGHT=6 WIDTH=6> <B><A HREF="#SOCKET_ACCEPT">SOCKET_ACCEPT</A></B></DT>
<DD>
A connection has been accepted by a ServerSocket.</DD>
<DT>
<IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/blue-ball-small.gif" ALT="o" HEIGHT=6 WIDTH=6> <B><A HREF="#SOCKET_ERROR">SOCKET_ERROR</A></B></DT>
<DD>
An error has occurred on a socket.</DD>
<DT>
<IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/blue-ball-small.gif" ALT="o" HEIGHT=6 WIDTH=6> <B><A HREF="#SOCKET_INPUT">SOCKET_INPUT</A></B></DT>
<DD>
A Socket is ready for reading.</DD>
</DL>
<H2>
<IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/constructor-index.gif" ALT="Constructor Index" HEIGHT=38 WIDTH=275></H2>
<DL>
<DT>
<IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/yellow-ball-small.gif" ALT="o" HEIGHT=6 WIDTH=6> <B><A HREF="#Selector()">Selector</A></B>()</DT>
<DD>
Construct an Selector object.</DD>
</DL>
<H2>
<IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/method-index.gif" ALT="Method Index" HEIGHT=38 WIDTH=207></H2>
<DL>
<DT>
<IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/red-ball-small.gif" ALT="o" HEIGHT=6 WIDTH=6> <B><A HREF="#add(java.lang.Object)">add</A></B>(Object)</DT>
<DD>
Add a Socket or ServerSocket object to list of sockets.</DD>
<DT>
<IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/red-ball-small.gif" ALT="o" HEIGHT=6 WIDTH=6> <B><A HREF="#addActionListener(java.awt.event.ActionListener)">addActionListener</A></B>(ActionListener)</DT>
<DD>
Adds the specified action listener to receive socket events from this selector.</DD>
<DT>
<IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/red-ball-small.gif" ALT="o" HEIGHT=6 WIDTH=6> <B><A HREF="#get(int)">get</A></B>(int)</DT>
<DD>
Return the Socket or ServerSocket object with index i.</DD>
<DT>
<IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/red-ball-small.gif" ALT="o" HEIGHT=6 WIDTH=6> <B><A HREF="#getDebug()">getDebug</A></B>()</DT>
<DD>
Get value of debug flag.</DD>
<DT>
<IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/red-ball-small.gif" ALT="o" HEIGHT=6 WIDTH=6> <B><A HREF="#remove(java.lang.Object)">remove</A></B>(Object)</DT>
<DD>
Remove a Socket or ServerSocket from list of sockets.</DD>
<DT>
<IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/red-ball-small.gif" ALT="o" HEIGHT=6 WIDTH=6> <B><A HREF="#removeActionListener(java.awt.event.ActionListener)">removeActionListener</A></B>(ActionListener)</DT>
<DD>
Removes the specified action listener so that it no longer receives socket
events from this selector.</DD>
<DT>
<IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/red-ball-small.gif" ALT="o" HEIGHT=6 WIDTH=6> <B><A HREF="#select()">select</A></B>()</DT>
<DD>
Blocks until all socket handlers have terminated.</DD>
<DT>
<IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/red-ball-small.gif" ALT="o" HEIGHT=6 WIDTH=6> <B><A HREF="#setDebug(boolean)">setDebug</A></B>(boolean)</DT>
<DD>
Set value of debug flag.</DD>
<DT>
<IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/red-ball-small.gif" ALT="o" HEIGHT=6 WIDTH=6> <B><A HREF="#shutdown()">shutdown</A></B>()</DT>
<DD>
Terminate all socket handlers.</DD>
</DL>
<A NAME="variables"></A>
<H2>
<IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/variables.gif" ALT="Variables" HEIGHT=38 WIDTH=153></H2>
<A NAME="SOCKET_ACCEPT"></A><IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/blue-ball.gif" ALT="o" HEIGHT=12 WIDTH=12>
<B>SOCKET_ACCEPT</B>
<PRE> public static final int SOCKET_ACCEPT</PRE>
<DL>
<DD>
A connection has been accepted by a ServerSocket.</DD>
<P> </DL>
<A NAME="SOCKET_INPUT"></A><IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/blue-ball.gif" ALT="o" HEIGHT=12 WIDTH=12>
<B>SOCKET_INPUT</B>
<PRE> public static final int SOCKET_INPUT</PRE>
<DL>
<DD>
A Socket is ready for reading.</DD>
<P> </DL>
<A NAME="SOCKET_ERROR"></A><IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/blue-ball.gif" ALT="o" HEIGHT=12 WIDTH=12>
<B>SOCKET_ERROR</B>
<PRE> public static final int SOCKET_ERROR</PRE>
<DL>
<DD>
An error has occurred on a socket.</DD>
<P> </DL>
<A NAME="constructors"></A>
<H2>
<IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/constructors.gif" ALT="Constructors" HEIGHT=38 WIDTH=231></H2>
<A NAME="Selector"></A><A NAME="Selector()"></A><IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/yellow-ball.gif" ALT="o" HEIGHT=12 WIDTH=12>
<B>Selector</B>
<PRE> public Selector()</PRE>
<DL>
<DD>
Construct an Selector object.</DD>
</DL>
<A NAME="methods"></A>
<H2>
<IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/methods.gif" ALT="Methods" HEIGHT=38 WIDTH=151></H2>
<A NAME="setDebug(boolean)"></A><IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/red-ball.gif" ALT="o" HEIGHT=12 WIDTH=12> <A NAME="setDebug"></A><B>setDebug</B>
<PRE> public void setDebug(boolean d)</PRE>
<DL>
<DD>
Set value of debug flag.</DD>
</DL>
<A NAME="getDebug()"></A><IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/red-ball.gif" ALT="o" HEIGHT=12 WIDTH=12> <A NAME="getDebug"></A><B>getDebug</B>
<PRE> public boolean getDebug()</PRE>
<DL>
<DD>
Get value of debug flag.</DD>
</DL>
<A NAME="add(java.lang.Object)"></A><IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/red-ball.gif" ALT="o" HEIGHT=12 WIDTH=12> <A NAME="add"></A><B>add</B>
<PRE> public synchronized int add(Object s) throws IllegalStateException</PRE>
<DL>
<DD>
Add a Socket or ServerSocket object to list of sockets.</DD>
</DL>
<A NAME="remove(java.lang.Object)"></A><IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/red-ball.gif" ALT="o" HEIGHT=12 WIDTH=12> <A NAME="remove"></A><B>remove</B>
<PRE> public synchronized boolean remove(Object s)</PRE>
<DL>
<DD>
Remove a Socket or ServerSocket from list of sockets.</DD>
</DL>
<A NAME="addActionListener(java.awt.event.ActionListener)"></A><IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/red-ball.gif" ALT="o" HEIGHT=12 WIDTH=12> <A NAME="addActionListener"></A><B>addActionListener</B>
<PRE> public synchronized void addActionListener(ActionListener l) throws TooManyListenersException</PRE>
<DL>
<DD>
Adds the specified action listener to receive socket events from this selector.</DD>
</DL>
<A NAME="removeActionListener(java.awt.event.ActionListener)"></A><IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/red-ball.gif" ALT="o" HEIGHT=12 WIDTH=12> <A NAME="removeActionListener"></A><B>removeActionListener</B>
<PRE> public synchronized void removeActionListener(ActionListener l)</PRE>
<DL>
<DD>
Removes the specified action listener so that it no longer receives socket
events from this selector.</DD>
</DL>
<A NAME="select()"></A><IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/red-ball.gif" ALT="o" HEIGHT=12 WIDTH=12> <A NAME="select"></A><B>select</B>
<PRE> public void select()</PRE>
<DL>
<DD>
Blocks until all socket handlers have terminated.</DD>
</DL>
<A NAME="shutdown()"></A><IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/red-ball.gif" ALT="o" HEIGHT=12 WIDTH=12> <A NAME="shutdown"></A><B>shutdown</B>
<PRE> public void shutdown()</PRE>
<DL>
<DD>
Terminate all socket handlers.</DD>
</DL>
<A NAME="get(int)"></A><IMG SRC="http://www.javasoft.com/products/jdk/1.1/docs/api/images/red-ball.gif" ALT="o" HEIGHT=12 WIDTH=12> <A NAME="get"></A><B>get</B>
<PRE> public Object get(int i)</PRE>
<DL>
<DD>
Return the Socket or ServerSocket object with index i.</DD>
</DL>
<HR>
<PRE><A HREF="Sockets.java">Sample Program</A> Copyright (c) XWare, Inc. 1997. <A HREF="mailto:plm@bellatlantic.net">Request a Copy</A></PRE>
</BODY>
</HTML>
--------------B3EBE34E629232795E0F82F6--
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads