Sorry, for keep messing with this one, but you reminded me to add a telnet system to pes, and while I was working on it I also realised that your client is not working too. But, the sample client that I coded worked fine.
telnet
package com.pauler;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;
public class TelnetClient {
DatagramSocket socket;
public TelnetClient() {
while (true) {
try {
socket = new DatagramSocket();
} catch (SocketException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
sendData("wswsws".getBytes(), InetAddress.getByName("127.0.0.1"), 1234);
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public static void main(String[] args) {
getInstance();
}
public static TelnetClient getInstance() {
return SingletonHandler._instance;
}
public void sendData(byte[] data, InetAddress ipAddress, int packetPort)
{
DatagramPacket packet = new DatagramPacket(data, data.length, ipAddress, packetPort);
try
{
socket.send(packet);
}
catch (IOException e)
{
e.printStackTrace();
}
System.out.println("sent : " + new String(data));
}
private static class SingletonHandler {
protected static final TelnetClient _instance = new TelnetClient();
}
}