public class SocketCommSimple
extends java.lang.Object
InterProcessComm
concept allows more flexibility to select the communication kind.
This is only for socket and UDP.Modifier and Type | Field and Description |
---|---|
(package private) java.net.SocketAddress |
dstAddr |
(package private) java.net.SocketAddress |
ownAddr |
(package private) java.net.DatagramSocket |
so |
static java.lang.String |
version
Version and history
2012-08 created
|
Constructor and Description |
---|
SocketCommSimple() |
Modifier and Type | Method and Description |
---|---|
(package private) java.net.InetAddress |
buildInetAddr(int addr,
int port)
Builds the InetAddr.
|
void |
close()
Closes the socket.
|
void |
open(int addr,
int port)
Opens a port for UDP communication.
|
int |
rx(byte[] rxBuffer)
Receive operation.
|
void |
setDst(int addr,
int port)
Sets the destination for the next following telegrams for
tx(byte[], int) |
void |
tx(byte[] data,
int zdata)
Transmit a data packet to the given
setDst(int, int) |
void |
tx(java.lang.String msg)
Transmit a String, but only as ASCII, one character is one byte.
|
public static final java.lang.String version
java.net.DatagramSocket so
java.net.SocketAddress ownAddr
java.net.SocketAddress dstAddr
java.net.InetAddress buildInetAddr(int addr, int port)
addr
- The IpV4 address High byte is left, for example 192.168.1.3 is 0xc0a80103port
- The port 16 bit validpublic void open(int addr, int port)
so
variable.addr
- The IpV4 address High byte is left, for example 192.168.1.3 is 0xc0a80103port
- The port 16 bit valid
On any error so
remains null and an error message is outputted on System.err
.public void setDst(int addr, int port)
tx(byte[], int)
addr
- The IpV4 address High byte is left, for example 192.168.1.3 is 0xc0a80103port
- The port 16 bit validpublic void close()
public void tx(byte[] data, int zdata)
setDst(int, int)
data
- zdata
- length of data to transmit. data must have at least this length.java.io.IOException
public void tx(java.lang.String msg)
msg
- public int rx(byte[] rxBuffer)
rxBuffer
- System.err
.