|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--SSF.OS.UDP.udpSocket
The four socket variables: local_ip, remote_ip, local_port, remote_port identify an end2end UDP session, if at least the local_port, remote_ip and remote_port have valid values. Else if only local_port (and optionally local_ip) are valid, while remote_ip = remote_port = -1, this is a local 'listening server' socket.
The socket variables last_remote_ip, last_remote_port, last_local_ip store the source and destination of the last received UDP/IP header if this is a 'listening server socket', and they can be retrieved by the application that opened this socket.
UDP has no flow control, therefore for a UDP socket the write() operation sends nbytes of data (virtual or an object) immediately in a single UDP datagram if nbytes <= max_datagram_size set by DML attribute udpinit.max_datagram_size.
The UDP socket write() Continuation returns immediately after the datagram was passed through a chain of push() (or equivalent) methods to UDP, IP, and NIC; with a success() if the datagram was successfuly placed in the NIC output queue, and with the failure() if the datagram was dropped by either UDP (nbytes > max_datagram_size), or IP (no route to remote_ip), or by NIC (output queue overflow). Thus write() blocks only for zero elapsed simulation time.
However, UDP socket read() blocks until it receives the requested nbytes of virtual bytes. The socket owner may request to read an arbitrary number of virtual bytes (greater than max_datagram_size). SSF.OS.UDP application writers should keep in mind that since UDP is unreliable, the read() might block forever.
| Field Summary | |
ProtocolSession |
appsess
local application session that created this socket |
dataMessage |
emptyMsg
|
int |
last_local_ip
|
int |
last_remote_ip
|
int |
last_remote_port
|
int |
local_ip
|
int |
local_port
|
int |
remote_ip
|
int |
remote_port
|
udpSession |
udpsess
local UDP session associated with this socket |
udpSessionMaster |
udpsessMaster
|
| Constructor Summary | |
udpSocket(ProtocolSession caller,
socketMaster sm)
Constructors |
|
| Method Summary | |
void |
abort()
not supported for udp sockets |
void |
accept(socketAPI[] new_socket,
Continuation caller)
not supported for udp sockets |
void |
bind(int my_ip,
int my_port)
names a local socket. |
void |
close(Continuation caller)
Close a connection. |
void |
connect(int dest_ip,
int dest_port,
Continuation caller)
sets remote IP and UDP port number and creates a UDP session so that socket write() may be used to send UDP datagrams - non-blocking. |
void |
listen(int request_limit)
after bind(), create a UDP listening session so that read() may be used. |
void |
messageBuffer(dataMessage msg)
|
void |
read(byte[] buf,
int nbytes,
Continuation caller)
not supported for udp sockets |
void |
read(int nbytes,
Continuation caller)
Read pseudo-data received by the socket. |
void |
read(java.lang.Object[] obj,
int nbytes,
Continuation caller)
Read a data object received by the socket. |
void |
write(byte[] buf,
int nbytes,
Continuation caller)
not supported for udp sockets |
void |
write(int nbytes,
Continuation caller)
Write simulated pseudo-data to the socket. |
void |
write(java.lang.Object[] obj,
int nbytes,
Continuation caller)
Write a concrete data object to the socket. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public udpSession udpsess
public udpSessionMaster udpsessMaster
public ProtocolSession appsess
public int local_ip
public int remote_ip
public int local_port
public int remote_port
public int last_remote_ip
public int last_local_ip
public int last_remote_port
public dataMessage emptyMsg
| Constructor Detail |
public udpSocket(ProtocolSession caller,
socketMaster sm)
| Method Detail |
public void bind(int my_ip,
int my_port)
bind in interface socketAPImy_ip - local IP addressmy_port - local port numberpublic void listen(int request_limit)
listen in interface socketAPIrequest_limit - For tcpSocket, specifies the maximum number of connection
requests pending accept. Ignored by udpSocket.
public void connect(int dest_ip,
int dest_port,
Continuation caller)
throws ProtocolException
connect in interface socketAPIdest_ip - remote IP addressdest_port - remote port numbercaller - user-defined Continuation specifying the actions
to be taken when a connection is either successfully
established or an error is signalled.
ProtocolException
public void accept(socketAPI[] new_socket,
Continuation caller)
accept in interface socketAPInew_socket - one-element array that will contain the new connected
socket when Continuation returns successfully.caller - user-defined Continuation specifying the actions
to be taken when a connection is either successfully
accepted or an error is signalled.
public void write(java.lang.Object[] obj,
int nbytes,
Continuation caller)
socketAPI
write in interface socketAPIobj - user-defined array whose first element obj[0] will be sentnbytes - nominal size (in bytes) of the data object that defines
the transmitted payload sizecaller - user-defined Continuation specifying the actions
to be taken when either nbytes of (virtual) data is successfully
written or an error is signalled.
public void write(byte[] buf,
int nbytes,
Continuation caller)
write in interface socketAPInbytes - size of data to be transmittedcaller - user-defined Continuation specifying the actions
to be taken when either nbytes of data is successfully
written or an error is signalled.
public void write(int nbytes,
Continuation caller)
socketAPI
write in interface socketAPInbytes - number of bytes of pseudo-data that defines the
transmitted payload sizecaller - user-defined Continuation specifying the actions
to be taken when either nbytes of data is successfully
written or an error is signalled.
public void read(byte[] buf,
int nbytes,
Continuation caller)
read in interface socketAPInbytes - expected received data sizecaller - user-defined Continuation specifying the actions
to be taken when either all data is read successfully
or an error is signalled.public void abort()
abort in interface socketAPI
public void read(java.lang.Object[] obj,
int nbytes,
Continuation caller)
socketAPI
read in interface socketAPIobj - user-defined array whose first element obj[0] will
contain the data object if read is successfulnbytes - expected number of received data bytescaller - user-defined Continuation specifying the actions
to be taken when either all data is read successfully
or an error is signalled.
public void read(int nbytes,
Continuation caller)
socketAPI
read in interface socketAPInbytes - expected number of bytes of received pseudo-datacaller - user-defined Continuation specifying the actions
to be taken when either all data is read successfully
or an error is signalled.
public void close(Continuation caller)
throws ProtocolException
socketAPI
close in interface socketAPIcaller - the user defined Continuation class which defines the
action should be taken when connection is either successfully
closed or an error is signalled.
ProtocolExceptionpublic void messageBuffer(dataMessage msg)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||