laith tarik
11-01-2006, 08:46 AM
i need to fill this program with the missing string for Echo server and client server so please help me
import java.io.*;
import java.net.*;
public class EchoUDPServer {
public static void main(String[] args)
throws IOException {
int port = Integer.parseInt(args[0]);
byte buffer[] = new byte[1024];
DatagramSocket echoSocket =
new DatagramSocket(port);
DatagramPacket packet =
new DatagramPacket(buffer, 1024);
while (true) {
echoSocket.receive(packet);
packet.setAddress(packet.getAddress());
packet.setPort(packet.getPort());
//++ change address and port in packet
//++ and return it.
}
}
}
the \echo client
import java.io.*;
import java.net.*;
public class EchoUDPClient {
public static void main(String[] args)
throws Exception {
DatagramSocket echoSocket;
DatagramPacket opacket;
InetAddress iaddr;
int port = 0;
//++ declare a datagram packet and byte array
//++ for returned datagram reception
iaddr = InetAddress.getByName(args[0]);
port = Integer.parseInt(args[1]);
echoSocket = new DatagramSocket();
//++create packet for returned datagram
thank you very much for the help
import java.io.*;
import java.net.*;
public class EchoUDPServer {
public static void main(String[] args)
throws IOException {
int port = Integer.parseInt(args[0]);
byte buffer[] = new byte[1024];
DatagramSocket echoSocket =
new DatagramSocket(port);
DatagramPacket packet =
new DatagramPacket(buffer, 1024);
while (true) {
echoSocket.receive(packet);
packet.setAddress(packet.getAddress());
packet.setPort(packet.getPort());
//++ change address and port in packet
//++ and return it.
}
}
}
the \echo client
import java.io.*;
import java.net.*;
public class EchoUDPClient {
public static void main(String[] args)
throws Exception {
DatagramSocket echoSocket;
DatagramPacket opacket;
InetAddress iaddr;
int port = 0;
//++ declare a datagram packet and byte array
//++ for returned datagram reception
iaddr = InetAddress.getByName(args[0]);
port = Integer.parseInt(args[1]);
echoSocket = new DatagramSocket();
//++create packet for returned datagram
thank you very much for the help



