|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A receiveport maintains connections to one or more sendports.
When creating a receiveport, it is possible to pass a
ReceivePortConnectUpcall
object. Ibis will call the
ReceivePortConnectUpcall.gotConnection(ReceivePort,
SendPortIdentifier)
upcall
of this object when a sendport tries to initiate a new
connection to the receiveport. When a connection is lost
for some reason (normal close or link error), the
ReceivePortConnectUpcall.lostConnection(ReceivePort,
SendPortIdentifier, Exception)
upcall is performed. Both upcalls are completely
asynchronous, but Ibis ensures that at most one is active at any given
time.
If no ReceivePortConnectUpcall
is registered, the user is NOT
informed of connections that are created or lost.
No exceptions are thrown by the read message when a connection is lost.
It is the user's own responsibility to use the lostConnections()
method to poll for connections that are lost. The newConnections()
method can be used to find out about new connections.
Only one upcall is alive at a one time, this includes BOTH
normal (message) upcalls AND ConnectUpcalls.
Only one message is alive at one time for a given
receiveport. This is done to prevent flow control problems.
A receiveport can be configured to generate upcalls or to
support blocking receive, but NOT both! The message object
is always destroyed when the upcall is finished; it is thus
not correct to put it in a global variable / queue.
Method Summary | |
void |
close()
Frees the resources held by the receiveport. |
void |
close(long timeoutMillis)
Frees the resources held by the receiveport, with timeout. |
SendPortIdentifier[] |
connectedTo()
Returns the set of sendports this receiveport is connected to . |
void |
disableConnections()
Disables the accepting of new connections. |
void |
disableUpcalls()
Prohibits message upcalls. |
void |
enableConnections()
Enables the accepting of new connections. |
void |
enableUpcalls()
Allows message upcalls to occur. |
long |
getCount()
Returns the number of bytes read from this receiveport. |
ReceivePortIdentifier |
identifier()
Returns the ReceivePortIdentifier of this receiveport. |
SendPortIdentifier[] |
lostConnections()
Returns the connections that were lost. |
java.lang.String |
name()
Returns the name of the receiveport. |
SendPortIdentifier[] |
newConnections()
Returns the new connections accepted by this receiveport. |
ReadMessage |
poll()
Asynchronous explicit receive. |
DynamicProperties |
properties()
Returns the DynamicProperties of
this port. |
ReadMessage |
receive()
Explicit blocking receive. |
ReadMessage |
receive(long timeoutMillis)
Explicit blocking receive with timeout. |
void |
resetCount()
Resets the counter for the number of bytes read from this receive port to zero. |
Method Detail |
public ReadMessage receive() throws java.io.IOException
IOException
is thrown.
java.io.IOException
- is thrown when the receiveport is configured
to use upcalls, or something else is wrong.public ReadMessage receive(long timeoutMillis) throws java.io.IOException
timeoutMillis
- timeout in milliseconds.
ReceiveTimedOutException
- is thrown when the timeout
expires and no message arrives.
java.io.IOException
- is thrown when the receiveport is configured
to use upcalls, or something else is wrong.public ReadMessage poll() throws java.io.IOException
null
.
java.io.IOException
- on IO error.public long getCount()
public void resetCount()
public DynamicProperties properties()
DynamicProperties
of
this port.
The user can set some implementation-specific dynamic properties of the
port, by means of the
DynamicProperties.set
method.
public ReceivePortIdentifier identifier()
ReceivePortIdentifier
of this receiveport.
public java.lang.String name()
public void enableConnections()
public void disableConnections()
enableConnections()
again
after invoking this method.
After this method returns, no more connection upcalls will be given.
public void enableUpcalls()
public void disableUpcalls()
enableUpcalls()
is called.
The disableUpcalls
/enableUpcalls
mechanism
allows the user to selectively allow or disallow message upcalls during
program run.
Note: the
disableUpcalls
/enableUpcalls
mechanism is not necessary to enforce serialization of Upcalls for
this port. Ibis already guarantees that only one message
per port is active at any time.
public void close() throws java.io.IOException
java.io.IOException
public void close(long timeoutMillis) throws java.io.IOException
close()
, but blocks at most timeout milliseconds.
When the close does not succeed within the timeout, this operation
does a forced close.
Important: this call does not block until all sendports that are
connected to it have been freed. Therefore, messages may be lost!
Use this with extreme caution!
When this call is used, and this port is configured to maintain
connection administration, it updates the administration and thus
may generate lostConnection upcalls.
timeoutMillis
- timeout in milliseconds. When zero, the call is
equivalent to a close()
; when less than zero, the port is
closed immediately.
java.io.IOException
public SendPortIdentifier[] connectedTo()
public SendPortIdentifier[] lostConnections()
null
is returned.
public SendPortIdentifier[] newConnections()
null
is returned.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |