private static void Receive(IntPtr info) { InternalReceive(info, false, (callmode, socket, data, buffer, ofs, count, flags, remoteep) => { int len = 0; if (callmode == 0) { SocketExtension.Receive(socket, buffer, 0, count, flags, out len); } else if (callmode == 1) { if (SocketExtension.Receive(socket, buffer, ofs, count, flags, out len)) { for (int i = ofs; i < len; i++) { data[i] = buffer[i]; } } } else { throw new NotSupportedException("callmode"); } return(len); }); }
private string ReadString(int len) { lock (_signal) { if (!_socket.Connected || SocketExtension.CleanedUp(_socket)) { return(null); } } byte[] buffer; if (!SocketExtension.Receive(_socket, 3, out buffer)) { return(null); } if (buffer == null) { return(null); } return(Encoding.UTF8.GetString(buffer)); }