UDP Packet content changes while transmitting

前端 未结 2 1068
甜味超标
甜味超标 2021-01-27 15:04

I\'m programming an Server-Client Software, where the client connects to the server with an port request, the server opens a new port and sends back the new port number. Then th

2条回答
  •  猫巷女王i
    2021-01-27 15:29

    inD = in.getData();
    

    This merely reasserts the same value. Remove.

    message = new String(inD,0,inD.length);
    

    Wrong. You're ignoring the actual length of the received datagram. Change to:

    message = new String(in.getData(), in.getOffset(), in.getLength());
    

提交回复
热议问题