|
Project 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
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.
Field Summary | |
protected int |
backlog
|
protected boolean |
bound
|
protected boolean |
closed
|
protected String |
closeLock
|
static String |
closeTag
|
protected boolean |
created
|
static String |
credTag
|
static String |
dataTag
|
protected PeerGroup |
group
|
protected StructuredDocument |
myCredentialDoc
|
static String |
nameSpace
|
protected PipeAdvertisement |
pipeadv
|
protected net.jxta.impl.util.UnbiasedQueue |
queue
|
static String |
remPeerTag
|
static String |
remPipeTag
|
static String |
reqPipeTag
|
protected InputPipe |
serverPipe
|
static String |
streamTag
|
protected int |
timeout
|
Constructor Summary | |
JxtaServerSocket()
default Constructor backlog default of 50 timeout defaults to 60 seconds, i.e. blocking. |
|
JxtaServerSocket(PeerGroup group,
PipeAdvertisement pipeadv)
Constructor for the JxtaServerSocket The backlog defaults to 50. |
|
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 The timeout defaults to 0, i.e. blocking. |
Method Summary | |
Socket |
accept()
Listens for a connection to be made to this socket and accepts it. |
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)
Unsupported operation, an IOException will be thrown |
void |
bind(SocketAddress endpoint,
int backlog)
Unsupported operation, an IOException will be thrown |
void |
close()
Closes this socket. |
PeerGroup |
getGroup()
Gets the group associated with this JxtaServerSocket object |
PipeAdvertisement |
getPipeAdv()
Gets the PipeAdvertisement associated with this JxtaServerSocket object |
int |
getSoTimeout()
Gets the Timeout attribute of the JxtaServerSocket object, specified in milliseconds. |
boolean |
isBound()
Returns the binding state of the JxtaServerSocket. |
boolean |
isClosed()
Returns the closed state of the JxtaServerSocket. |
protected static PipeAdvertisement |
newInputPipe(PeerGroup group,
PipeAdvertisement pipeadv)
Utility method newInputPipe is used to get new pipe advertisement (w/random pipe ID) from old one. |
void |
pipeMsgEvent(PipeMsgEvent event)
when request messages arrive this method is called |
protected void |
sendResponseMessage(PeerGroup group,
Messenger msgr,
PipeAdvertisement pipeAd)
Method sendResponseMessage get the createResponseMessage and sends it. |
protected void |
setBound()
Sets the bound attribute of the JxtaServerSocket object |
void |
setCredentialDoc(StructuredDocument doc)
Sets the connection credential doc If no credentials are set, the default group credential will be used |
void |
setSoTimeout(int timeout)
Sets the Timeout attribute of the JxtaServerSocket, specified in milliseconds. |
String |
toString()
|
Methods inherited from class java.net.ServerSocket |
getChannel, getInetAddress, getLocalPort, getLocalSocketAddress, getReceiveBufferSize, getReuseAddress, implAccept, setReceiveBufferSize, setReuseAddress, setSocketFactory |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final String nameSpace
public static final String credTag
public static final String reqPipeTag
public static final String remPeerTag
public static final String remPipeTag
public static final String dataTag
public static final String closeTag
public static final String streamTag
protected PeerGroup group
protected InputPipe serverPipe
protected PipeAdvertisement pipeadv
protected int backlog
protected int timeout
protected String closeLock
protected net.jxta.impl.util.UnbiasedQueue queue
protected boolean created
protected boolean bound
protected boolean closed
protected StructuredDocument myCredentialDoc
Constructor Detail |
public JxtaServerSocket() throws IOException
backlog default of 50
timeout defaults to 60 seconds, i.e. blocking.
A call to bind() is needed to finish initializing this object.
public JxtaServerSocket(PeerGroup group, PipeAdvertisement pipeadv) throws IOException
The backlog defaults to 50.
The timeout default to 60 seconds, i.e. blocking.
group
- JXTA PeerGrouppipeadv
- PipeAdvertisement on which pipe requests are accepted
IOException
- if an I/O error occurspublic 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(PeerGroup group, PipeAdvertisement pipeadv, int backlog, int timeout) throws IOException
The timeout defaults to 0, i.e. blocking.
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 occursMethod Detail |
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
IOException
public void bind(SocketAddress endpoint, int backlog) throws IOException
IOException
public Socket accept() throws IOException
IOException
- if an I/O error occurspublic PeerGroup getGroup()
public PipeAdvertisement getPipeAdv()
public void close() throws IOException
IOException
- if an I/O error occursprotected void setBound()
public int getSoTimeout() throws IOException
IOException
- if an I/O error occurspublic void setSoTimeout(int timeout) throws SocketException
timeout
- The new soTimeout value
IOException
- if an I/O error occurs
SocketException
public boolean isClosed()
public boolean isBound()
public void pipeMsgEvent(PipeMsgEvent event)
pipeMsgEvent
in interface PipeMsgListener
event
- the pipe message eventprotected void sendResponseMessage(PeerGroup group, Messenger msgr, PipeAdvertisement pipeAd) throws IOException
group
- msgr
- pipeAd
-
IOException
protected static PipeAdvertisement newInputPipe(PeerGroup group, PipeAdvertisement pipeadv)
Called by JxtaSocket to make pipe (name -> name.remote) for open message
Called by JxtaServerSocket to make pipe (name.remote -> name.remote.remote) for response message
group
- pipeadv
- to get the basename and type from
public void setCredentialDoc(StructuredDocument doc)
doc
- Credential StructuredDocumentpublic String toString()
|
JXTA J2SE | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |