public class InterProcessComm_SocketImpl extends java.lang.Object implements InterProcessComm
Modifier and Type | Field and Description |
---|---|
private static int |
kDataBufferSize |
private Address_InterProcessComm_Socket |
ownAddress |
private java.lang.String |
sRxErrorMsg |
private java.lang.String |
sTxErrorMsg |
private java.net.DatagramSocket |
udpSocket
The UDP Socket handling as receiver
|
receiverShouldbeBlocking, receiverShouldbePolling, version
Constructor and Description |
---|
InterProcessComm_SocketImpl(Address_InterProcessComm ownAddress) |
Modifier and Type | Method and Description |
---|---|
int |
abortReceive()
Abort receiving function
|
int |
capacityToSendWithoutBlocking(int nrofBytesToSend)
Tests wether a next send is done without blocking.
|
int |
checkConnection()
Checks the connection.
|
int |
close()
Closes the mailbox, only to be called on shutdown of the application.
|
Address_InterProcessComm |
createAddress()
Creates an empty instance for a address information, especially for the sender.
|
Address_InterProcessComm |
createAddress(int p1,
int p2) |
Address_InterProcessComm |
createAddress(java.lang.String address) |
Address_InterProcessComm |
createAddress(java.lang.String p1,
int p2) |
int |
dataAvailable()
Tests wether data are available to receive.
|
boolean |
equals(Address_InterProcessComm address1,
Address_InterProcessComm address2)
Compare the address to another address, returns true if it is the same address.
|
int |
flush()
Flushs send data to destination.
|
void |
freeData(byte[] data)
Relinguishes the data buffer, after it is evaluated.
|
java.lang.String |
getName() |
Address_InterProcessComm |
getOwnAddress()
Gets the own address of this interProcessComm, it are the receive parameters.
|
java.lang.String |
getReceiveErrorMsg(boolean clearIt) |
byte[] |
getSendBuffer(int len)
Gets a buffer for send.
|
java.lang.String |
getSendErrorMsg(boolean clearIt) |
int |
open(Address_InterProcessComm dstAddress,
boolean shouldBlock)
Opens the Communication.
|
byte[] |
receive(int[] result,
Address_InterProcessComm senderP)
Receives a Datagram.
|
byte[] |
receiveData(int[] result,
byte[] bufferP,
Address_InterProcessComm senderP) |
int |
send(byte[] data,
int nBytes,
Address_InterProcessComm addresseeP)
Sends Data.
|
java.lang.String |
translateErrorMsg(int nError) |
private static final int kDataBufferSize
private final Address_InterProcessComm_Socket ownAddress
private java.net.DatagramSocket udpSocket
private java.lang.String sRxErrorMsg
private java.lang.String sTxErrorMsg
public InterProcessComm_SocketImpl(Address_InterProcessComm ownAddress)
public int open(Address_InterProcessComm dstAddress, boolean shouldBlock)
InterProcessComm
open
in interface InterProcessComm
dstAddress
- The own address to which this interprocess-port is assigned.
This address is also used
when calling send() as information about the sender of the data.public int close()
InterProcessComm
close
in interface InterProcessComm
public int send(byte[] data, int nBytes, Address_InterProcessComm addresseeP)
InterProcessComm
send
in interface InterProcessComm
data
- The data to be sent. The user should not touch the buffer after calling here.nBytes
- The number of bytes to be send.addresseeP
- The addressee, the receiver of the message. If it is a fix connection (TCP),
then this parameter should be null. It isn't used. The addressee is given
on #open(Address_InterProcessComm, int)
-request.public byte[] receive(int[] result, Address_InterProcessComm senderP)
InterProcessComm
receive
in interface InterProcessComm
result
- result[0] = Nr of Bytes sendet, if >=0. If <0 its an error code.senderP
- Buffer for the sender of the message.public void freeData(byte[] data)
InterProcessComm
freeData
in interface InterProcessComm
data
- The buffer delivered from receive!public boolean equals(Address_InterProcessComm address1, Address_InterProcessComm address2)
InterProcessComm
equals
in interface InterProcessComm
public java.lang.String getReceiveErrorMsg(boolean clearIt)
public java.lang.String getSendErrorMsg(boolean clearIt)
public int abortReceive()
InterProcessComm
abortReceive
in interface InterProcessComm
public int capacityToSendWithoutBlocking(int nrofBytesToSend)
InterProcessComm
capacityToSendWithoutBlocking
in interface InterProcessComm
public int checkConnection()
InterProcessComm
checkConnection
in interface InterProcessComm
public int dataAvailable()
InterProcessComm
dataAvailable
in interface InterProcessComm
public int flush()
InterProcessComm
flush
in interface InterProcessComm
public java.lang.String getName()
getName
in interface InterProcessComm
public Address_InterProcessComm getOwnAddress()
InterProcessComm
getOwnAddress
in interface InterProcessComm
public byte[] getSendBuffer(int len)
InterProcessComm
getSendBuffer
in interface InterProcessComm
public byte[] receiveData(int[] result, byte[] bufferP, Address_InterProcessComm senderP)
receiveData
in interface InterProcessComm
public java.lang.String translateErrorMsg(int nError)
translateErrorMsg
in interface InterProcessComm
public Address_InterProcessComm createAddress()
InterProcessComm
createAddress
in interface InterProcessComm
public Address_InterProcessComm createAddress(int p1, int p2)
createAddress
in interface InterProcessComm
public Address_InterProcessComm createAddress(java.lang.String p1, int p2)
createAddress
in interface InterProcessComm
public Address_InterProcessComm createAddress(java.lang.String address)
createAddress
in interface InterProcessComm