private static int strlen(byte[] buffer) { for (int i = 0; i < buffer.Length; i++) { if (buffer[i] == 0) return (i + 1); } return buffer.Length; }