May 2001
Intermediate to advanced
1088 pages
30h 13m
English
Following the idea of the TCP relay, a UDP datagram relay receives datagrams on a particular port number and resends them to another address and port.
Listing 31.3 shows a simple datagram relay.
package usingj2ee.net;
import java.net.*;
import java.io.*;
public class DatagramRelay
{
public static void main(String[] args)
{
if (args.length < 3)
{
System.out.println("Please supply a local port, a remote host "+
" and a remote port.");
System.exit(0);
}
int localPort = 0;
try
{
localPort = Integer.parseInt(args[0]);
}
catch (Exception exc)
{
System.out.println("Invalid local port: "+args[0]);
System.exit(0);
} int remotePort = 0; try { remotePort = Integer.parseInt(args[2]); ... |
Read now
Unlock full access