我有一个C#客户端,可以从Java套接字服务器发送和接收数据。当从服务器到客户端立交桥1399的输出数据分为两部分时收到:
有没有办法阻止它分裂?
服务器端代码:
if(outData.size() == 0) return;
try {
if(!socketChannel.isOpen()) return;
byte[] bytesArray = outData.toByteArray();
outData.reset();
ByteBuffer buffer = ByteBuffer.allocateDirect(bytesArray.length);
buffer.put(bytesArray);
buffer.flip();
socketChannel.write(buffer);
} catch (IOException e) {
disconnect();
e.printStackTrace();
}
客户端代码:
clientSocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
recieveBuffer = new byte[8142];
try
{
clientSocket.Connect("111.111.111.111",9889));
}
catch(SocketException ex)
{
Debug.Log(ex.Message);
}
clientSocket.BeginReceive(recieveBuffer,0,recieveBuffer.Length,SocketFlags.None,new AsyncCallback(ReceiveCallback),null);