Package drivers
Class UDPSocket
java.lang.Object
drivers.UDPSocket
A socket for UDP transactions.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
bind
(MC68000Cpu cpu) Binds a socket.void
close()
Close the socket.int
connect
(MC68000Cpu cpu) Connects a socket - sets peer address with port and addressGets the connection status.int
Gets the last error from this socket.getName()
Gets the name of the current socket, including address, port and connection status.int
getRemote
(MC68000Cpu cpu) Get info on the remote host, put it at (A1).boolean
isClosed()
Checks whether the peer channel for a UDD channel is closed (i recieved an empty UDP packet).boolean
Anything still pending?boolean
isUDD()
int
receive
(MC68000Cpu cpu, int size, boolean checkD1, byte[] destination) Receive bytes from the port and copy them : either to (A1), updating A1 and D1, or into a destination byte array.on entry, D1 MAY hold a flag, which COULD be as follows 0x0 // no flag MSG_OOB 0x1 // process out-of-band data MSG_PEEK 0x2 /* peek at incoming message MSG_DONTROUTE 0x4 /* send without using routing tables MSG_EOR 0x8 /* data completes record MSG_TRUNC 0x10 /* data discarded before delivery MSG_CTRUNC 0x20 /* control data lost before delivery MSG_WAITALL 0x40 /* wait for full request or error for the time being, only case 0 is honoured.int
receive1Byte
(MC68000Cpu cpu, byte[] byt) Receive one byte from the port and return it.int
receiveAndCheckForLF
(MC68000Cpu cpu, int size) Receive bytes from the port and copy them to (A1),up to the first LF encountered.int
receiveFrom
(MC68000Cpu cpu, int size) Implements receiveFrom (rcvfrm).int
send
(MC68000Cpu cpu, int size, InetSocketAddress socketAddress) Send bytes out over the port.int
send1Byte
(byte byt) Send one byte out over the socket.int
sendTo
(MC68000Cpu cpu, int pointer, int size) Implemnnt send to facility.void
setLastError
(int err) Sets the last error for the socket.
-
Constructor Details
-
UDPSocket
Create a socket.- Parameters:
cpu
- the cpu used.
-
-
Method Details
-
close
public void close()Close the socket. -
getConnectionStatus
Gets the connection status.- Returns:
- the connection status, one of UDPSocket.CONN_STATUS.
-
getLastError
public int getLastError()Gets the last error from this socket.- Returns:
- the last error encountered by the socket.
-
setLastError
public void setLastError(int err) Sets the last error for the socket.- Parameters:
err
- the last error encountered by the socket when send/receiving,connecting/listening.
-
bind
Binds a socket. This means the local port and address are set.- Parameters:
cpu
- the smsqmulator.cpu.MC68000Cpu object.- Returns:
- 0 or SMSQ/E error code.
-
connect
Connects a socket - sets peer address with port and address- Parameters:
cpu
- the smsqmulator.cpu.MC68000Cpu (A2 points to a sockaddr structure)- Returns:
- SMSQ/E error code or 0
-
send
Send bytes out over the port.- Parameters:
cpu
- the cpu to get data to be sent from, it lies at (A1), ndr of bytes to be sent in D2.L.size
- nbr of bytes to sendsocketAddress
-- Returns:
- error code (0=ok, negative = SMSQ/E error code).
-
send1Byte
public int send1Byte(byte byt) Send one byte out over the socket.- Parameters:
byt
- the byte to send- Returns:
- 0 or SMSQ/E error.
-
sendTo
Implemnnt send to facility.- Parameters:
cpu
-pointer
-size
-- Returns:
-
receive
Receive bytes from the port and copy them : either to (A1), updating A1 and D1, or into a destination byte array.on entry, D1 MAY hold a flag, which COULD be as follows 0x0 // no flag MSG_OOB 0x1 // process out-of-band data MSG_PEEK 0x2 /* peek at incoming message MSG_DONTROUTE 0x4 /* send without using routing tables MSG_EOR 0x8 /* data completes record MSG_TRUNC 0x10 /* data discarded before delivery MSG_CTRUNC 0x20 /* control data lost before delivery MSG_WAITALL 0x40 /* wait for full request or error for the time being, only case 0 is honoured. Does case 2 make sense?- Parameters:
cpu
- the CPU used.size
- nbr of bytes to readcheckD1
- if true, should check D1 for flags, else ignore D1.destination
- if not null, a byte array into which to receive, if null, copy to cpumem at A1- Returns:
- SMSQ/E negative error code or the number of bytes I got This implements some primitive buffereing, as follows: - if there is no packet received, get one, using the timeout provided by SMSQE send as many bytes as required/possible to SMSQE, updating the next byte out pointer; if SMSQE aksed for less bytes than in the packet, do nothing more if SMSQE asked for more byte, send the one got set err.nc
-
receiveAndCheckForLF
Receive bytes from the port and copy them to (A1),up to the first LF encountered.- Parameters:
cpu
- the CPU used.size
- nbr of bytes to read- Returns:
- SMSQ/E negative error code or the number of bytes I got (for buufer comments, see method just above)
-
receive1Byte
Receive one byte from the port and return it. for the time being, only cases 0 and 2 are honoured.- Parameters:
cpu
- the CPU used.byt
- a byte array with ONE ELEMENT ONLY into which the byte goes, may not be null.- Returns:
- SMSQ/E error code or 0 if all ok.
-
receiveFrom
Implements receiveFrom (rcvfrm).- Parameters:
cpu
-size
-- Returns:
-
getRemote
Get info on the remote host, put it at (A1). at A1 lies : family, port, ipv4 address. On return D1.L = length of answer. On entry, D2.L = length of buffer- Parameters:
cpu
- the cpu used- Returns:
- SMSQ/E error code (0 if no error).
-
getName
Gets the name of the current socket, including address, port and connection status.- Returns:
- the full name, e.g "TCP_localport@local_address | peerport@peer_ip_addresst".
-
isUDD
public boolean isUDD()- Returns:
- the isUDD
-
isClosed
public boolean isClosed()Checks whether the peer channel for a UDD channel is closed (i recieved an empty UDP packet).- Returns:
- true if peer channel is closed.
-
isPending
public boolean isPending()Anything still pending?- Returns:
-