Package drivers

Class UDPSocket

java.lang.Object
drivers.UDPSocket

public class UDPSocket extends Object
A socket for UDP transactions.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a socket.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Binds a socket.
    void
    Close the socket.
    int
    Connects a socket - sets peer address with port and address
    Gets the connection status.
    int
    Gets the last error from this socket.
    Gets the name of the current socket, including address, port and connection status.
    int
    Get info on the remote host, put it at (A1).
    boolean
    Checks whether the peer channel for a UDD channel is closed (i recieved an empty UDP packet).
    boolean
    Anything still pending?
    boolean
     
    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
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • UDPSocket

      public UDPSocket(MC68000Cpu cpu)
      Create a socket.
      Parameters:
      cpu - the cpu used.
  • Method Details

    • close

      public void close()
      Close the socket.
    • getConnectionStatus

      public UDPSocket.CONN_STATUS 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

      public int bind(MC68000Cpu cpu)
      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

      public int connect(MC68000Cpu cpu)
      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

      public int send(MC68000Cpu cpu, int size, InetSocketAddress socketAddress)
      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 send
      socketAddress -
      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

      public int sendTo(MC68000Cpu cpu, int pointer, int size)
      Implemnnt send to facility.
      Parameters:
      cpu -
      pointer -
      size -
      Returns:
    • receive

      public 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. Does case 2 make sense?
      Parameters:
      cpu - the CPU used.
      size - nbr of bytes to read
      checkD1 - 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

      public int receiveAndCheckForLF(MC68000Cpu cpu, int size)
      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

      public int receive1Byte(MC68000Cpu cpu, byte[] byt)
      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

      public int receiveFrom(MC68000Cpu cpu, int size)
      Implements receiveFrom (rcvfrm).
      Parameters:
      cpu -
      size -
      Returns:
    • getRemote

      public int getRemote(MC68000Cpu cpu)
      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

      public String 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: