|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object soc.server.genericServer.LocalStringServerSocket
public class LocalStringServerSocket
Clients who want to connect, call connectTo and are queued. (Thread.wait is used internally) Server-side calls accept to retrieve them.
1.0.0 - 2007-11-18 - initial release 1.0.3 - 2008-08-08 - add change history; no other changes in this file since 1.0.0 1.0.4 - 2008-09-04 - no change in this file 1.0.5 - 2009-05-31 - no change in this file 1.0.5.1- 2009-10-26- no change in this file
Field Summary | |
---|---|
static int |
ACCEPT_QUEUELENGTH
Length of queue for accepting new connections; default 100. |
protected java.util.Vector<LocalStringConnection> |
acceptQueue
Waiting client connections (client-peer sides); Added by connectClient, removed by accept method |
protected java.util.Vector<LocalStringConnection> |
allConnected
Server-peer sides of connected clients; Added by accept method |
protected static java.util.Hashtable<java.lang.String,LocalStringServerSocket> |
allSockets
|
(package private) boolean |
out_setEOF
|
private java.lang.String |
socketName
|
private java.lang.Object |
sync_out_setEOF
|
Constructor Summary | |
---|---|
LocalStringServerSocket(java.lang.String name)
|
Method Summary | |
---|---|
StringConnection |
accept()
For server to call. |
java.util.Enumeration<LocalStringConnection> |
allClients()
|
void |
broadcast(java.lang.String msg)
Send to all connected clients. |
void |
close()
Close down server socket immediately: Do not let inbound data drain. |
static LocalStringConnection |
connectTo(java.lang.String name)
Find and connect to stringport with this name. |
static LocalStringConnection |
connectTo(java.lang.String name,
LocalStringConnection client)
Find and connect to stringport with this name. |
void |
disconnectEOFClients()
If our server won't receive any more data from the client, disconnect them. |
java.lang.String |
getSocketName()
|
boolean |
isOutEOF()
Have we closed our outbound side? |
protected LocalStringConnection |
queueAcceptClient(LocalStringConnection client)
Queue this client to be accepted, and return their new server-peer; if calling this from methods initiated by the client, check if accepted. |
void |
setEOF()
Close down server socket, but don't disconnect anyone: Accept no new inbound connections. |
protected void |
setEOF(boolean forceDisconnect)
Close down server socket, possibly disconnect everyone; For use by setEOF() and close(). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static java.util.Hashtable<java.lang.String,LocalStringServerSocket> allSockets
public static int ACCEPT_QUEUELENGTH
protected java.util.Vector<LocalStringConnection> allConnected
protected java.util.Vector<LocalStringConnection> acceptQueue
private java.lang.String socketName
boolean out_setEOF
private java.lang.Object sync_out_setEOF
Constructor Detail |
---|
public LocalStringServerSocket(java.lang.String name)
Method Detail |
---|
public static LocalStringConnection connectTo(java.lang.String name) throws java.net.ConnectException, java.lang.IllegalArgumentException
name
- Stringport server name to connect to
java.net.ConnectException
- If stringport name is not found, or is EOF,
or if its connect/accept queue is full.
java.lang.IllegalArgumentException
- If name is nullpublic static LocalStringConnection connectTo(java.lang.String name, LocalStringConnection client) throws java.net.ConnectException, java.lang.IllegalArgumentException
name
- Stringport server name to connect toclient
- Existing unused connection object to connect with
java.net.ConnectException
- If stringport name is not found, or is EOF,
or if its connect/accept queue is full.
java.lang.IllegalArgumentException
- If name is null, client is null,
or client is already peered/connected.protected LocalStringConnection queueAcceptClient(LocalStringConnection client) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException, java.net.ConnectException, java.io.EOFException
client
- Client to queue to accept
java.lang.IllegalStateException
- If we are at EOF already
java.lang.IllegalArgumentException
- If client is or was accepted somewhere already
java.net.ConnectException
- If accept queue is full (ACCEPT_QUEUELENGTH)
java.io.EOFException
- If client is at EOF alreadyaccept()
,
ACCEPT_QUEUELENGTH
public StringConnection accept() throws java.net.SocketException, java.io.IOException
accept
in interface StringServerSocket
java.net.SocketException
- if our setEOF() has been called, thus
new clients won't receive any data from us
java.io.IOException
- if a network problem occurs (Which won't happen with this local communication)public java.util.Enumeration<LocalStringConnection> allClients()
public void broadcast(java.lang.String msg)
msg
- String to sendallClients()
public void disconnectEOFClients()
public java.lang.String getSocketName()
public void setEOF()
close()
protected void setEOF(boolean forceDisconnect)
forceDisconnect
- Call disconnect on clients, or just send them an EOF marker?close()
,
LocalStringConnection.disconnect()
,
LocalStringConnection.setEOF()
public boolean isOutEOF()
close()
,
setEOF()
public void close() throws java.io.IOException
close
in interface StringServerSocket
java.io.IOException
setEOF()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |