日期:2014-05-17 浏览次数:21186 次
while (true) { byte[] buffer = SocketEx.Receive(socketClient, this.BefferSize); if (buffer == null) continue; ………… }
public static byte[] Receive(Socket socket, int beffersize) { try { using (MemoryStream ms = new MemoryStream()) { socket.Receive(befferSize, 4, SocketFlags.None); int dataLength = BitConverter.ToInt32(befferSize, 0); //判断读取字节为0 if (dataLength == 0) return null; ………… ………… return ms.ToArray(); } } catch (Exception ex) { throw ex; } }