DCT Lightfoot v3 API specification

com.dctl.j2me.net
Class UDP

java.lang.Object
  |
  +--com.dctl.j2me.net.UDP

public class UDP
extends Object

This wraps up all the UDP socket methods


Constructor Summary
UDP()
           
 
Method Summary
static void bind(int handle, int address, int port)
          Bind the socket to a port and address
static void close(int handle)
          Close a socket
static int createSocket()
          Create a new socket
static int receive(int handle, byte[] buf, int off, int len, com.dctl.j2me.io.datagram.DatagramImplementation dgram)
          Receive a datagram
static void send(int handle, byte[] buf, int off, int len, int address, int port)
          Send a datagram
static void send(int handle, int b, int address, int port)
          Send a single byte in a datagram
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UDP

public UDP()
Method Detail

createSocket

public static int createSocket()
                        throws IOException
Create a new socket

Returns:
the handle to use
Throws:
IOException - if there is an error

bind

public static void bind(int handle,
                        int address,
                        int port)
                 throws IOException
Bind the socket to a port and address

Parameters:
handle - The handle
address - The address of the interface to bind to
port - The port to bind to
Throws:
IOException - if there is an error

close

public static void close(int handle)
                  throws IOException
Close a socket

Parameters:
handle - The handle
Throws:
IOException - if there is an error

receive

public static int receive(int handle,
                          byte[] buf,
                          int off,
                          int len,
                          com.dctl.j2me.io.datagram.DatagramImplementation dgram)
                   throws IOException
Receive a datagram

Parameters:
handle - The handle
buf - The buffer
off - The offset into the buffer
len - The maximum length to read
dgram - The datagram object to write the remote address and port to
Returns:
the number of bytes read or -1 if EOF
Throws:
IOException - if there is an error

send

public static void send(int handle,
                        byte[] buf,
                        int off,
                        int len,
                        int address,
                        int port)
                 throws IOException
Send a datagram

Parameters:
handle - The handle
buf - The buffer
off - The offset into the buffer
len - The maximum length to write
address - The address to send to
port - The port to send to
Throws:
IOException - if there is an error

send

public static void send(int handle,
                        int b,
                        int address,
                        int port)
                 throws IOException
Send a single byte in a datagram

Parameters:
handle - The handle
b - The byte
address - The address to send to
port - The port to send to
Throws:
IOException - if there is an error

DCT Lightfoot v3 API specification

DCT Lightfoot v3 API specification