Public Member Functions | |
DatagramSocket () | |
DatagramSocket (int port) | |
DatagramSocket (int port, InetAddress laddr) | |
~DatagramSocket () | |
void | bind (int lport, InetAddress laddress) |
void | create () |
void | close () |
void | connect (InetAddress address, int port) |
InetAddress | getInetAddress () const |
InetAddress | getLocalAddress () const |
int | getLocalPort () const |
int | getPort () const |
bool | isBound () const |
bool | isClosed () const |
bool | isConnected () const |
void | receive (DatagramPacketPtr &p) |
void | send (DatagramPacketPtr &p) |
Protected Attributes | |
int | fd |
int | localPort |
DatagramSocket | ( | ) |
Constructs a datagram socket and binds it to any available port on the local host machine.
DatagramSocket | ( | int | port | ) |
Constructs a datagram socket and binds it to the specified port on the local host machine.
DatagramSocket | ( | int | port, | |
InetAddress | laddr | |||
) |
Creates a datagram socket, bound to the specified local address.
~DatagramSocket | ( | ) |
ensure the socket is closed.
void bind | ( | int | lport, | |
InetAddress | laddress | |||
) |
Binds a datagram socket to a local port and address.
void create | ( | ) |
Creates a datagram socket.
void close | ( | ) |
Closes this datagram socket
void connect | ( | InetAddress | address, | |
int | port | |||
) |
Connects the socket to a remote address for this socket.
InetAddress getInetAddress | ( | ) | const [inline] |
Returns the address to which this socket is connected.
InetAddress getLocalAddress | ( | ) | const [inline] |
Gets the local address to which the socket is bound.
int getLocalPort | ( | ) | const [inline] |
Returns the port number on the local host to which this socket is bound.
int getPort | ( | ) | const [inline] |
Returns the port for this socket
bool isBound | ( | ) | const [inline] |
Returns the binding state of the socket.
bool isClosed | ( | ) | const [inline] |
Returns wether the socket is closed or not.
bool isConnected | ( | ) | const [inline] |
Returns the connection state of the socket.
void receive | ( | DatagramPacketPtr & | p | ) |
Receives a datagram packet from this socket.
void send | ( | DatagramPacketPtr & | p | ) |
Sends a datagram packet from this socket.
int fd [protected] |
The file descriptor object for this socket.
int localPort [protected] |
The local port number to which this socket is connected.