WiBro, which is used as a server module and client Nexus Galaxy ICS. Both machines are 3g UDP communication. The server will return only the received data has been implemented.
dSocket.send (sendPacket) is a smooth communication. However, we have a problem. dSocket.receive (recvPacket) does not receive the data.
The server sends the packet is wrong? If the client receives the packet is wrong? The server sends data but, telecom equipment is taken to preserve the situation?
When only sending a packet, the client has not a problem. but after receive code implementation, the client has a problem.
private class ClientThread implements Runnable{
@SuppressWarnings("finally")
@Override
public void run() {
// TODO Auto-generated method stub
DatagramSocket dSocket = null;
try{
InetAddress serverAddr = InetAddress.getByName(serverIpAddress.toString());
Log.d(TAG, "Connecting");
Log.d(TAG, "IP :::: " + serverAddr.toString());
dSocket = new DatagramSocket(SERVERPORT);
dSocket.setSoTimeout(5000);
byte[] arr_RecvPacket = new byte[1024];
connected = true;
while(connected){
try{
Log.d(TAG, "Sending Command :::: ( " + String.valueOf(i));
String strPacket = "Hey Server ( " + String.valueOf(i);
byte[] arr_Packet = strPacket.getBytes();
sendPacket = new DatagramPacket(arr_Packet, arr_Packet.length, serverAddr, SERVERPORT);
dSocket.send(sendPacket);
Log.d(TAG, "C:Send");
i++;
Log.d(TAG, "C:Make Recv Packet....");
recvPacket = new DatagramPacket(arr_RecvPacket, arr_RecvPacket.length);
Log.d(TAG, "C:Recving...");
dSocket.receive(recvPacket);
handler.sendEmptyMessage(0x01);
Thread.sleep(4000);
}catch(Exception e){
e.printStackTrace();
Log.d(TAG, "S:Error");
}
}
Log.d(TAG, "S:DataSocket close");
dSocket.close();
}catch(Exception e){
Log.d(TAG, "C:Error");
e.printStackTrace();
connected = false;
}finally{
connected = false;
if(dSocket != null){
dSocket.close();
}
return;
}
}
}