|
JXTA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.net.ServerSocket
net.jxta.socket.JxtaServerSocket
public class JxtaServerSocket
JxtaServerSocket is a bi-directional Pipe that behaves very much like ServerSocket. It creates an inputpipe and listens for pipe connection requests. JxtaServerSocket also defines it own protocol. Requests arrive as a JXTA Message with the following elements:
<Cred> Credentials which can be used to determine trust </Cred> <reqPipe> requestor's pipe advertisement </reqPipe> <remPipe> Remote pipe advertisement </remPipe> <reqPeer> Remote peer advertisement </reqPeer> <stream> determine whether the connection is reliable, or not </stream> <close> close request </close> <data> Data </data> JxtaServerSocket then creates a new private pipe, listens for messages on that pipe, resolves the requestor's pipe, and sends a <remPipe> private pipe created </remotePipe> advertisement back, where the remote side is resolved. Theaccept()
backlog defaults to 50 requests.
The timeout default to 60 seconds, i.e. blocking.
Field Summary | |
---|---|
protected int |
backlog
The number of connect requests we will allow to become backlogged. |
protected boolean |
bound
|
protected static String |
closeAckValue
|
protected boolean |
closed
|
protected static String |
closeReqValue
|
protected static String |
closeTag
|
protected static String |
credTag
|
protected static String |
dataTag
|
protected PeerGroup |
group
The PeerGroup |
protected Credential |
localCredential
The credential we will present to connect requests. |
protected static String |
MSG_ELEMENT_NAMESPACE
|
protected PipeAdvertisement |
pipeAdv
The pipe advertisement we are serving. |
protected BlockingQueue<Message> |
queue
|
protected static Message |
QUEUE_END_MESSAGE
QUEUE_END_MESSAGE is used to signal that the queue has been closed. |
protected static String |
remPeerTag
|
protected static String |
remPipeTag
|
protected static String |
reqPipeTag
|
protected InputPipe |
serverPipe
The input pipe on which we listen for connect requests. |
protected static String |
streamTag
|
protected long |
timeout
The timeout for accept operations. |
Constructor Summary | |
---|---|
JxtaServerSocket()
Default Constructor A call to bind() is needed to finish initializing this object. |
|
JxtaServerSocket(PeerGroup group,
PipeAdvertisement pipeAdv)
Constructs and binds a JxtaServerSocket to the specified pipe. |
|
JxtaServerSocket(PeerGroup group,
PipeAdvertisement pipeAdv,
int backlog)
Constructor for the JxtaServerSocket object |
|
JxtaServerSocket(PeerGroup group,
PipeAdvertisement pipeAdv,
int backlog,
int timeout)
Constructor for the JxtaServerSocket object. |
|
JxtaServerSocket(PeerGroup group,
PipeAdvertisement pipeAdv,
int backlog,
int timeout,
CredentialValidator credValidator)
Constructor for the JxtaServerSocket object. |
|
JxtaServerSocket(SocketAddress address)
Constructs and binds a JxtaServerSocket using a JxtaSocketAddress as the address. |
|
JxtaServerSocket(SocketAddress address,
int backlog)
Constructs and binds a JxtaServerSocket using a JxtaSocketAddress as the address. |
|
JxtaServerSocket(SocketAddress address,
int backlog,
int timeout)
Constructs and binds a JxtaServerSocket using a JxtaSocketAddress as the address. |
Method Summary | |
---|---|
Socket |
accept()
|
void |
bind(PeerGroup group,
PipeAdvertisement pipeAdv)
Binds the JxtaServerSocket to a specific pipe advertisement |
void |
bind(PeerGroup group,
PipeAdvertisement pipeadv,
int backlog)
Binds the JxtaServerSocket to a specific pipe advertisement |
void |
bind(SocketAddress endpoint)
Used to bind a JxtaServerSocket created with the no-arg constructor. |
void |
bind(SocketAddress endpoint,
int backlog)
Used to bind a JxtaServerSocket created with the no-arg constructor. |
void |
close()
|
protected JxtaSocket |
createEphemeralSocket(PeerGroup group,
PipeAdvertisement pipeAdv,
PipeAdvertisement remoteEphemeralPipeAdv,
PeerAdvertisement remotePeerAdv,
Credential localCredential,
Credential credential,
boolean isReliable)
Construct the emphemeral socket result from accept. |
protected void |
finalize()
Closes the JxtaServerPipe. |
PeerGroup |
getGroup()
Gets the group associated with this JxtaServerSocket object |
SocketAddress |
getLocalSocketAddress()
|
PipeAdvertisement |
getPipeAdv()
Gets the PipeAdvertisement associated with this JxtaServerSocket object |
int |
getSoTimeout()
|
boolean |
isBound()
|
boolean |
isClosed()
|
void |
pipeMsgEvent(PipeMsgEvent event)
Called for each pipe message event that occurs. |
void |
setCredential(Credential localCredential)
Sets the credential to be used by this socket connection. |
void |
setSoTimeout(int timeout)
|
String |
toString()
This output is suitable for debugging but should not be parsed. |
Methods inherited from class java.net.ServerSocket |
---|
getChannel, getInetAddress, getLocalPort, getReceiveBufferSize, getReuseAddress, implAccept, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSocketFactory |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final String MSG_ELEMENT_NAMESPACE
protected static final String credTag
protected static final String reqPipeTag
protected static final String remPeerTag
protected static final String remPipeTag
protected static final String dataTag
protected static final String closeTag
protected static final String closeReqValue
protected static final String closeAckValue
protected static final String streamTag
protected static final Message QUEUE_END_MESSAGE
protected PeerGroup group
protected PipeAdvertisement pipeAdv
protected InputPipe serverPipe
protected Credential localCredential
protected int backlog
protected long timeout
protected BlockingQueue<Message> queue
protected volatile boolean bound
protected volatile boolean closed
Constructor Detail |
---|
public JxtaServerSocket() throws IOException
bind()
is needed to finish initializing this object.
IOException
- if an io error occurspublic JxtaServerSocket(SocketAddress address) throws IOException
address
- an instance of JxtaSocketAddress
IOException
- if an io error occursJxtaSocketAddress
public JxtaServerSocket(PeerGroup group, PipeAdvertisement pipeAdv) throws IOException
group
- JXTA PeerGrouppipeAdv
- PipeAdvertisement on which pipe requests are accepted
IOException
- if an I/O error occurspublic JxtaServerSocket(SocketAddress address, int backlog) throws IOException
address
- an instance of JxtaSocketAddressbacklog
- the size of the backlog queue
IOException
- if an I/O error occursJxtaSocketAddress
public JxtaServerSocket(PeerGroup group, PipeAdvertisement pipeAdv, int backlog) throws IOException
group
- JXTA PeerGrouppipeAdv
- PipeAdvertisement on which pipe requests are acceptedbacklog
- the maximum length of the queue.
IOException
- if an I/O error occurspublic JxtaServerSocket(SocketAddress address, int backlog, int timeout) throws IOException
address
- an instance of JxtaSocketAddressbacklog
- the size of the backlog queuetimeout
- connection timeout in milliseconds
IOException
- if an I/O error occursJxtaSocketAddress
public JxtaServerSocket(PeerGroup group, PipeAdvertisement pipeAdv, int backlog, int timeout) throws IOException
group
- JXTA PeerGrouppipeAdv
- PipeAdvertisement on which pipe requests are acceptedbacklog
- the maximum length of the queue.timeout
- the specified timeout, in milliseconds
IOException
- if an I/O error occurspublic JxtaServerSocket(PeerGroup group, PipeAdvertisement pipeAdv, int backlog, int timeout, CredentialValidator credValidator) throws IOException
group
- JXTA PeerGrouppipeAdv
- PipeAdvertisement on which pipe requests are acceptedbacklog
- the maximum length of the queue.timeout
- the specified timeout, in millisecondscredValidator
- the CredentialValidator
IOException
- if an I/O error occursMethod Detail |
---|
protected void finalize() throws Throwable
finalize
in class Object
Throwable
public Socket accept() throws IOException
accept
in class ServerSocket
IOException
public void bind(PeerGroup group, PipeAdvertisement pipeAdv) throws IOException
JxtaServerSocket
to a specific pipe advertisement
group
- JXTA PeerGrouppipeAdv
- PipeAdvertisement on which pipe requests are accepted
IOException
- if an I/O error occurspublic void bind(PeerGroup group, PipeAdvertisement pipeadv, int backlog) throws IOException
JxtaServerSocket
to a specific pipe advertisement
group
- JXTA PeerGrouppipeadv
- PipeAdvertisement on which pipe requests are acceptedbacklog
- the maximum length of the queue.
IOException
- if an I/O error occurspublic void bind(SocketAddress endpoint) throws IOException
bind
in class ServerSocket
IOException
public void bind(SocketAddress endpoint, int backlog) throws IOException
bind
in class ServerSocket
IOException
public void close() throws IOException
close
in class ServerSocket
IOException
public SocketAddress getLocalSocketAddress()
getLocalSocketAddress
in class ServerSocket
ServerSocket.getLocalSocketAddress()
public int getSoTimeout() throws IOException
getSoTimeout
in class ServerSocket
IOException
public void setSoTimeout(int timeout) throws SocketException
setSoTimeout
in class ServerSocket
SocketException
public boolean isBound()
isBound
in class ServerSocket
public boolean isClosed()
isClosed
in class ServerSocket
public PeerGroup getGroup()
public PipeAdvertisement getPipeAdv()
public void pipeMsgEvent(PipeMsgEvent event)
pipeMsgEvent
in interface PipeMsgListener
event
- The event being received.protected JxtaSocket createEphemeralSocket(PeerGroup group, PipeAdvertisement pipeAdv, PipeAdvertisement remoteEphemeralPipeAdv, PeerAdvertisement remotePeerAdv, Credential localCredential, Credential credential, boolean isReliable) throws IOException
group
- The peer group for the socket.pipeAdv
- The public pipe advertisement.remoteEphemeralPipeAdv
- The pipe advertisement of the remote peer's
ephemeral pipe.remotePeerAdv
- The peer advertisement of the remote peer.localCredential
- Our credential.credential
- The credential of the remote peer.isReliable
- if true, uses the reliability library in non-direct mode
IOException
- if an io error occurspublic void setCredential(Credential localCredential)
localCredential
- The credential to be used for connection responses
or null if the default credential is to be used.public String toString()
toString
in class ServerSocket
|
JXSE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |