|
Project JXTA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.net.Socket
net.jxta.socket.JxtaSocket
public class JxtaSocket
JxtaSocket is a bi-directional Pipe, that behaves very much like a Socket, it creates an InputPipe and listens for pipe connection request. JxtaSocket defines its 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 </remPeer>
<stream> determine whether the connection is reliable, or not </stream>
<close> close request </close>
<data> Data </data>
Field Summary | |
---|---|
protected String |
acceptLock
|
protected boolean |
bound
|
protected boolean |
closed
|
protected String |
closeLock
|
protected OutputPipe |
connectOutpipe
|
protected Credential |
credential
|
protected StructuredDocument |
credentialDoc
|
protected String |
finalLock
|
protected PeerGroup |
group
|
protected InputPipe |
in
|
protected String |
instrLock
|
protected boolean |
isStream
|
protected Messenger |
msgr
|
protected StructuredDocument |
myCredentialDoc
|
protected PipeAdvertisement |
myPipeAdv
|
protected net.jxta.impl.util.pipe.reliable.OutgoingMsgrAdaptor |
outgoing
|
protected PeerID |
peerid
|
protected PipeAdvertisement |
pipeAdv
|
protected PipeService |
pipeSvc
|
protected net.jxta.impl.util.UnbiasedQueue |
queue
|
protected net.jxta.impl.util.pipe.reliable.ReliableInputStream |
ris
|
protected net.jxta.impl.util.pipe.reliable.ReliableOutputStream |
ros
|
protected InputStream |
stream
|
protected int |
timeout
|
protected boolean |
waiting
|
protected int |
windowSize
|
Constructor Summary | |
---|---|
|
JxtaSocket()
Constructor for the JxtaSocket, this constructor does not establish a connection use this constructor when altering the default parameters, and options of the socket by default connections are unreliable, and the default timeout is 60 seconds to alter a connection a call to create(true) changes the connection to a reliable one. |
protected |
JxtaSocket(PeerGroup group,
Messenger msgr,
PipeAdvertisement pipe,
StructuredDocument credDoc,
boolean isStream)
Constructor for the JxtaSocket, this constructor does not establish a connection use this constructor when altering the default parameters, and options of the socket by default connections are unreliable, and the default timeout is 60 seconds to alter a connection a call to create(true) changes the connection to a reliable one. |
|
JxtaSocket(PeerGroup group,
PeerID peerid,
PipeAdvertisement pipeAd,
int timeout)
Create a JxtaSocket to any peer listening on pipeAdv this attempts establish a connection to specified pipe within a context of group and within timeout specified in milliseconds |
|
JxtaSocket(PeerGroup group,
PeerID peerid,
PipeAdvertisement pipeAd,
int timeout,
boolean stream)
Create a JxtaSocket to any peer listening on pipeAdv this attempts establish a connection to specified pipe within a context of group and within timeout specified in milliseconds |
|
JxtaSocket(PeerGroup group,
PipeAdvertisement pipeAd)
Create a JxtaSocket to any peer listening on pipeAdv |
|
JxtaSocket(PeerGroup group,
PipeAdvertisement pipeAd,
int timeout)
Create a JxtaSocket to any peer listening on pipeAdv this attempts establish a connection to specified pipe within the context of the specified group within timeout specified in milliseconds |
Method Summary | |
---|---|
protected int |
available()
Returns the number of bytes that can be read (or skipped over) from this input stream. |
void |
bind(SocketAddress address)
Unsupported operation, an IOException will be thrown |
void |
close()
Closes this socket. |
protected void |
closeCommon()
In stream mode, closes everything but the input stream. closeFromRemote() leaves it open until EOF is reached. |
protected void |
closeFromRemote()
This is called when closure is initiated on the remote side. |
void |
connect(PeerGroup group,
PeerID peerid,
PipeAdvertisement pipeAd,
int timeout)
Connects to a remote JxtaSocket on a specific peer within a timeout specified in milliseconds |
void |
connect(PeerGroup group,
PipeAdvertisement pipeAd)
Connects to a remote JxtaSocket on any peer within the default timeout of 60 seconds |
void |
connect(PeerGroup group,
PipeAdvertisement pipeAd,
int timeout)
Connects to a remote JxtaSocket on any peer within a timeout specified in milliseconds |
void |
connect(SocketAddress address)
Unsupported operation, an IOException will be thrown |
void |
connect(SocketAddress address,
int i)
Unsupported operation, an IOException will be thrown |
void |
create(boolean stream)
Creates either a stream or a datagram socket. default is a datagram |
protected Message |
createOpenMessage(PeerGroup group,
PipeAdvertisement pipeAd)
Create a connection request message |
protected static StructuredDocument |
getCredDoc(PeerGroup group)
obtain the cred doc from the group object |
StructuredDocument |
getCredentialDoc()
get the remote credential doc |
InputStream |
getInputStream()
Returns an input stream for this socket. |
boolean |
getKeepAlive()
|
OutputStream |
getOutputStream()
Returns an output stream for this socket. |
int |
getOutputStreamBufferSize()
Returns the OutputStream buffer size |
int |
getReceiveBufferSize()
|
int |
getSendBufferSize()
|
int |
getSoTimeout()
Gets the Timeout attribute of the JxtaServerSocket object |
int |
getTrafficClass()
|
int |
getWindowSize()
When in reliable mode, gets the Reliable library window size |
boolean |
isBound()
Returns the binding state of the JxtaServerSocket. |
boolean |
isClosed()
Returns the closed state of the JxtaServerSocket. |
boolean |
isConnected()
|
boolean |
isInputShutdown()
|
protected static Messenger |
lightweightOutputPipe(PeerGroup group,
PipeAdvertisement pipeAdv,
PeerAdvertisement peer)
A lightweight output pipe constructor, note the return type Since all the info needed is available, there's no need for to use the pipe service to resolve the pipe we have all we need to construct a messenger. |
void |
listen(int backlog)
Sets the maximum queue length for incoming connection indications (a request to connect) to the count argument. |
void |
outputPipeEvent(OutputPipeEvent event)
the output pipe event |
void |
pipeMsgEvent(PipeMsgEvent event)
we got a message |
protected int |
read()
Performs on behalf of JxtaSocketInputStream. |
protected int |
read(byte[] b,
int off,
int len)
Performs on behalf of JxtaSocketInputStream. |
void |
sendUrgentData(int data)
|
void |
setCredentialDoc(StructuredDocument doc)
Sets the connection credential doc If no credentials are set, the default group credential will be used |
protected void |
setInputPipe(InputPipe in)
Sets the inputPipe attribute of the JxtaSocket object |
void |
setKeepAlive(boolean state)
|
void |
setOOBInline(boolean state)
|
void |
setOutputStreamBufferSize(int size)
Sets the OutputStream buffer size this operation is only valid prior to any call to getOutputStream |
void |
setSendBufferSize(int size)
|
static void |
setSocketImplFactory(SocketImplFactory factory)
Not a supported operation, an exception will be thrown |
void |
setSoTimeout(int timeout)
Sets the Timeout attribute of the JxtaServerSocket a timeout of 0 blocks forever. |
void |
setTrafficClass(int tc)
|
void |
setWindowSize(int windowSize)
When in reliable mode, sets the Reliable library window size |
void |
shutdownInput()
|
void |
shutdownOutput()
|
String |
toString()
|
protected void |
write(byte[] buf,
int offset,
int length)
Performs on behalf of JxtaSocketOutputStream. |
Methods inherited from class java.net.Socket |
---|
getChannel, getInetAddress, getLocalAddress, getLocalPort, getLocalSocketAddress, getOOBInline, getPort, getRemoteSocketAddress, getReuseAddress, getSoLinger, getTcpNoDelay, isOutputShutdown, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSoLinger, setTcpNoDelay |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected PeerGroup group
protected PipeAdvertisement pipeAdv
protected PipeAdvertisement myPipeAdv
protected PipeService pipeSvc
protected PeerID peerid
protected InputPipe in
protected OutputPipe connectOutpipe
protected Messenger msgr
protected InputStream stream
protected int timeout
protected int windowSize
protected final String closeLock
protected final String acceptLock
protected final String instrLock
protected final String finalLock
protected boolean closed
protected boolean bound
protected final net.jxta.impl.util.UnbiasedQueue queue
protected Credential credential
protected StructuredDocument credentialDoc
protected StructuredDocument myCredentialDoc
protected boolean isStream
protected net.jxta.impl.util.pipe.reliable.OutgoingMsgrAdaptor outgoing
protected net.jxta.impl.util.pipe.reliable.ReliableInputStream ris
protected net.jxta.impl.util.pipe.reliable.ReliableOutputStream ros
protected boolean waiting
Constructor Detail |
---|
public JxtaSocket()
protected JxtaSocket(PeerGroup group, Messenger msgr, PipeAdvertisement pipe, StructuredDocument credDoc, boolean isStream) throws IOException
group
- group contextmsgr
- lightweight output pipepipe
- PipeAdvertisementcredDoc
- remote node's crendetial StructuredDocument
IOException
- if an io error occurspublic JxtaSocket(PeerGroup group, PipeAdvertisement pipeAd) throws IOException
group
- group contextpipeAd
- PipeAdvertisement
IOException
- if an io error occurspublic JxtaSocket(PeerGroup group, PipeAdvertisement pipeAd, int timeout) throws IOException
group
- group contextpipeAd
- PipeAdvertisementtimeout
- JxtaSocket timeout in milliseconds
IOException
- if an io error occurspublic JxtaSocket(PeerGroup group, PeerID peerid, PipeAdvertisement pipeAd, int timeout) throws IOException
group
- group contextpeerid
- peer to connect topipeAd
- PipeAdvertisementtimeout
- JxtaSocket timeout in milliseconds
IOException
- if an io error occurspublic JxtaSocket(PeerGroup group, PeerID peerid, PipeAdvertisement pipeAd, int timeout, boolean stream) throws IOException
group
- group contextpeerid
- peer to connect topipeAd
- PipeAdvertisementtimeout
- JxtaSocket timeout in milliseconds
IOException
- if an io error occursMethod Detail |
---|
public void create(boolean stream) throws IOException
stream
- if true
, create a stream socket;
otherwise, create a datagram socket.
IOException
- if an I/O error occurs while creating the
socket.public void bind(SocketAddress address) throws IOException
bind
in class Socket
IOException
public void connect(SocketAddress address) throws IOException
connect
in class Socket
IOException
public void connect(SocketAddress address, int i) throws IOException
connect
in class Socket
IOException
public void connect(PeerGroup group, PipeAdvertisement pipeAd) throws IOException
group
- group contextpipeAd
- PipeAdvertisement
IOException
- if an io error occurspublic void connect(PeerGroup group, PipeAdvertisement pipeAd, int timeout) throws IOException
group
- group contextpipeAd
- PipeAdvertisement
IOException
- if an io error occurspublic void connect(PeerGroup group, PeerID peerid, PipeAdvertisement pipeAd, int timeout) throws IOException
group
- group contextpeerid
- peer to connect topipeAd
- PipeAdvertisementtimeout
- timeout in milliseconds
IOException
- if an io error occursprotected static StructuredDocument getCredDoc(PeerGroup group)
group
- group context
public StructuredDocument getCredentialDoc()
public void setCredentialDoc(StructuredDocument doc)
doc
- Credential StructuredDocumentprotected Message createOpenMessage(PeerGroup group, PipeAdvertisement pipeAd) throws IOException
group
- group contextpipeAd
- pipe advertisement
IOException
public void listen(int backlog) throws IOException
count
argument. If a
connection indication arrives when the queue is full, the connection
is refused.
backlog
- the maximum length of the queue.
IOException
- if an I/O error occurs when creating the
queue.public boolean isBound()
isBound
in class Socket
public int getOutputStreamBufferSize()
public void setOutputStreamBufferSize(int size) throws IOException
IOException
public InputStream getInputStream() throws IOException
getInputStream
in class Socket
IOException
- if an I/O error occurs when creating the
input stream.public OutputStream getOutputStream() throws IOException
getOutputStream
in class Socket
IOException
- if an I/O error occurs when creating the
output stream.public void close() throws IOException
close
in class Socket
IOException
- if an I/O error occurs when closing this
socket.protected void closeFromRemote() throws IOException
IOException
protected void closeCommon() throws IOException
IOException
protected void setInputPipe(InputPipe in)
in
- The new inputPipe valuepublic void pipeMsgEvent(PipeMsgEvent event)
pipeMsgEvent
in interface PipeMsgListener
event
- the message eventpublic void outputPipeEvent(OutputPipeEvent event)
outputPipeEvent
in interface OutputPipeListener
event
- the eventprotected static Messenger lightweightOutputPipe(PeerGroup group, PipeAdvertisement pipeAdv, PeerAdvertisement peer)
group
- group contextpipeAdv
- Remote Pipe Advertisementpeer
- Remote Peer Advertisment
public int getSoTimeout() throws SocketException
getSoTimeout
in class Socket
IOException
- if an I/O error occurs
SocketException
public void setSoTimeout(int timeout) throws SocketException
setSoTimeout
in class Socket
timeout
- The new soTimeout value
IOException
- if an I/O error occurs
SocketException
public int getWindowSize()
IOException
- if an I/O error occurspublic void setWindowSize(int windowSize) throws SocketException
windowSize
- The new window size value
IOException
- if an I/O error occurs
SocketException
public boolean isClosed()
isClosed
in class Socket
protected void write(byte[] buf, int offset, int length) throws IOException
IOException
OutputStream.write(int)
protected int read() throws IOException
IOException
InputStream.read()
protected int read(byte[] b, int off, int len) throws IOException
IOException
InputStream.read()
protected int available() throws IOException
IOException
- - if an I/O error occurs.public int getSendBufferSize() throws SocketException
getSendBufferSize
in class Socket
SocketException
public void setSendBufferSize(int size) throws SocketException
setSendBufferSize
in class Socket
SocketException
public int getReceiveBufferSize() throws SocketException
getReceiveBufferSize
in class Socket
SocketException
public boolean getKeepAlive() throws SocketException
getKeepAlive
in class Socket
SocketException
public int getTrafficClass() throws SocketException
getTrafficClass
in class Socket
SocketException
public void setTrafficClass(int tc) throws SocketException
setTrafficClass
in class Socket
SocketException
public boolean isInputShutdown()
isInputShutdown
in class Socket
public void sendUrgentData(int data) throws IOException
sendUrgentData
in class Socket
IOException
public void setOOBInline(boolean state) throws SocketException
setOOBInline
in class Socket
SocketException
public void setKeepAlive(boolean state) throws SocketException
setKeepAlive
in class Socket
SocketException
public static void setSocketImplFactory(SocketImplFactory factory) throws IOException
IOException
public void shutdownInput() throws IOException
shutdownInput
in class Socket
IOException
public void shutdownOutput() throws IOException
shutdownOutput
in class Socket
IOException
public boolean isConnected()
isConnected
in class Socket
public String toString()
toString
in class Socket
|
JXTA J2SE | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |