sockets.datagram.packet

behaviour

create

(create)(create len)(create buf len)(create buf arg2 arg3)(create buf arg2 arg3 arg4)(create buf offset len addr port)

A constructor for datagram packets. This function may take 0, 1, 2, 3, 4, or 5 args.

  • 0-arity - This is a Clojure-only convenience constructor that creates a byte-array of length DEFAULT_PACKET_SIZE, suitable for receiving packets.
  • 1-arity - This is a Clojure-only convenience constructor that creates a byte-array of the desired length, suitable for receiving packets.
  • 2-arity - Constructs a DatagramPacket for receiving packets of length len.
  • 3-arity - Either of:
  • Constructs a DatagramPacket for receiving packets of length arg3, specifying an offset of arg2 into the buffer;
  • Constructs a datagram packet for sending packets of length arg2 to the specified SocketAddress of arg3.
  • 4-arity - Either of:
  • Constructs a datagram packet for sending packets of length arg2 to port arg4 on the specified host (InetAddress) arg3.
  • Constructs a datagram packet for sending packets of length arg3 with offset arg2 to the specified SocketAddress of arg4.
  • 5-arity - Constructs a datagram packet for sending packets of length len with offset offset to the specified port port on the specified host (InetAddress) addr.

DEFAULT_PACKET_SIZE

Packet

protocol

members

address

(address this)

Returns the IP address of the machine to which this datagram is being sent or from which the datagram was received.

address!

(address! this addr)

Sets the IP address of the machine to which this datagram is being sent.

data

(data this)

Returns the data buffer.

data!

(data! this bytes)(data! this bytes offset len)

Set the data buffer for this packet.

default-length

(default-length this)

A Clojure method only available to the Clojure wrapper, returning the default length a packet is created with when no length is given.

length

(length this)

Returns the length of the data to be sent or the length of the data received.

length!

(length! this len)

Set the length for this packet.

offset

(offset this)

Returns the offset of the data to be sent or the offset of the data received.

port

(port this)

Returns the port number on the remote host to which this datagram is being sent or from which the datagram was received.

port!

(port! this port)

Sets the port number on the remote host to which this datagram is being sent.

socket-address

(socket-address this)

Gets the SocketAddress (usually IP address + port number) of the remote host that this packet is being sent to or is coming from.

socket-address!

(socket-address! this)

Sets the SocketAddress (usually IP address + port number) of the remote host to which this datagram is being sent.

update-address

(update-address this addr)

Updates the IP address of the machine to which this datagram is being sent, returning the updated packet. This is provided as a convenience for use in Clojure threading macros.

update-data

(update-data this bytes)(update-data this bytes offset len)

Updates the data buffer for this packet, returning the updated packet. This is provided as a convenience for use in Clojure threading macros.

update-length

(update-length this len)

Set the length for this packet, returning the updated packet. This is provided as a convenience for use in Clojure threading macros.

update-port

(update-port this port)

Sets the port number on the remote host to which this datagram is being sent, returning the updated packet. This is provided as a convenience for use in Clojure threading macros.

update-socket-address

(update-socket-address this)

Sets the SocketAddress (usually IP address + port number) of the remote host to which this datagram is being sent, returning the updated packet. This is provided as a convenience for use in Clojure threading macros.