protected StreamContent(Byte[] contentBytes) { Debug.Assert(contentBytes != null); ContentBytes = contentBytes; ContentLength = (UInt32)contentBytes.Length; }
public void Write(Byte[] buffer, Int32 offset, Int32 count) { while (count > 0) { var requiredBytes = this.workingBuffer.Length - this.workingBufferOffset; var bytesToConsume = Math.Min(count, requiredBytes); Buffer.BlockCopy(buffer, offset, this.workingBuffer, this.workingBufferOffset, bytesToConsume); count -= bytesToConsume; offset += bytesToConsume; requiredBytes -= bytesToConsume; if (requiredBytes > 0) { this.workingBufferOffset += bytesToConsume; continue; } this.workingBufferOffset = 0; if (this.bufferingFrame) { this.availableFrames.Enqueue(new Frame(this.workingBuffer)); this.workingBuffer = this.sizeBuffer; this.bufferingFrame = false; } else { this.workingBuffer = new Byte[BitConverter.ToInt32(this.workingBuffer, 0)]; this.bufferingFrame = true; } } }
public GroupFoundEventArgs (Byte connection, UInt16 start, UInt16 end, Byte[] uuid) { this.connection = connection; this.start = start; this.end = end; this.uuid = uuid; }
// Create frame from scratch public Frame(FrameMeta.FrameIDs id, FrameFlags flags, String data) { bFrameId = (new UTF8Encoding()).GetBytes(id.ToString()); bFlags = flags.GetBytes(); sData = data; iSize = data.Length; }
public void HandShake() { try { client = new TcpClient(server, port); string hello = "HELLO"; data = System.Text.Encoding.ASCII.GetBytes(hello); stream = client.GetStream(); stream.Write(data, 0, data.Length); int i = stream.Read(bytes, 0, bytes.Length); string Data = System.Text.Encoding.ASCII.GetString(bytes, 0, i); if (Data == "HI") { //MessageBox.Show("Підключення з сервером встановлено успішно."); isConnected = true; toolStripMenuItem3.Enabled = true; toolStripMenuItem1.Enabled = false; } else { MessageBox.Show("Невдалось підключитись до сервера. Спробуйте пізніше.\n"); } } catch (Exception ex) { MessageBox.Show("Невдалось підключитись до сервера. Спробуйте пізніше.\n\n" + ex.ToString()); } }
public void InitData(Int32 length) { this.Data = new Byte[length]; this.totalLength = length; this.remaining = length; this.usered = 0; }
public void EaxEbpPlusDword12() { const int INDEX = 0x0c; code = new Byte[] {0x8b, 0x85, INDEX, 0x00, 0x00, 0x00}; Assert.IsTrue(ModRM.HasIndex(code)); Assert.AreEqual(INDEX, ModRM.GetIndexFor(code)); }
public BOCls_Photo() { oDBPhotoController = new DBCls_Photos(); ID = ""; PhotoSRC = new Byte[0]; ObjectStatus = (int)UserStatus.New; }
//Initializes, attaches it to archive internal ZipArchiveEntry(ZipArchive archive, ZipCentralDirectoryFileHeader cd) { _archive = archive; _originallyInArchive = true; _diskNumberStart = cd.DiskNumberStart; _versionToExtract = (ZipVersionNeededValues)cd.VersionNeededToExtract; _generalPurposeBitFlag = (BitFlagValues)cd.GeneralPurposeBitFlag; CompressionMethod = (CompressionMethodValues)cd.CompressionMethod; _lastModified = new DateTimeOffset(ZipHelper.DosTimeToDateTime(cd.LastModified)); _compressedSize = cd.CompressedSize; _uncompressedSize = cd.UncompressedSize; _offsetOfLocalHeader = cd.RelativeOffsetOfLocalHeader; /* we don't know this yet: should be _offsetOfLocalHeader + 30 + _storedEntryNameBytes.Length + extrafieldlength * but entryname/extra length could be different in LH */ _storedOffsetOfCompressedData = null; _crc32 = cd.Crc32; _compressedBytes = null; _storedUncompressedData = null; _currentlyOpenForWrite = false; _everOpenedForWrite = false; _outstandingWriteStream = null; FullName = DecodeEntryName(cd.Filename); _lhUnknownExtraFields = null; //the cd should have these as null if we aren't in Update mode _cdUnknownExtraFields = cd.ExtraFields; _fileComment = cd.FileComment; _compressionLevel = null; }
internal Response(Robot robot, ResponseCode code, Byte seqNum, Byte[] data) { Robot = robot; RspCode = code; SeqNum = seqNum; Data = data; }
public static void ReceiveFile() { try { Console.WriteLine("-----------*******Ожидайте получение файла*******-----------"); // Получаем файл receiveBytes = receivingUdpClient.Receive(ref RemoteIpEndPoint); // Преобразуем и отображаем данные Console.WriteLine("----Файл получен...Сохраняем..."); // Создаем временный файл с полученным расширением fs = new FileStream("temp." + fileDet.FILETYPE, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite); fs.Write(receiveBytes, 0, receiveBytes.Length); Console.WriteLine("----Файл сохранен..."); Console.WriteLine("-------Открытие файла------"); // Открываем файл связанной с ним программой Process.Start(fs.Name); } catch (Exception eR) { Console.WriteLine(eR.ToString()); } finally { fs.Close(); receivingUdpClient.Close(); Console.Read(); } }
private static void GetFileDetails() { try { Console.WriteLine("-----------*******Ожидание информации о файле*******-----------"); // Получаем информацию о файле receiveBytes = receivingUdpClient.Receive(ref RemoteIpEndPoint); Console.WriteLine("----Информация о файле получена!"); XmlSerializer fileSerializer = new XmlSerializer(typeof(FileDetails)); MemoryStream stream1 = new MemoryStream(); // Считываем информацию о файле stream1.Write(receiveBytes, 0, receiveBytes.Length); stream1.Position = 0; // Вызываем метод Deserialize fileDet = (FileDetails)fileSerializer.Deserialize(stream1); Console.WriteLine("Получен файл типа ." + fileDet.FILETYPE + " имеющий размер " + fileDet.FILESIZE.ToString() + " байт"); } catch (Exception eR) { Console.WriteLine(eR.ToString()); } }
internal WebSocketConnectionRfc6455(Stream clientStream, WebSocketListenerOptions options) { if (clientStream == null) throw new ArgumentNullException("clientStream"); if (options == null) throw new ArgumentNullException("options"); _writeSemaphore = new SemaphoreSlim(1); _options = options; _clientStream = clientStream; if (options.BufferManager != null) _buffer = options.BufferManager.TakeBuffer(14 + 125 + 125 + 8 + 10 + _options.SendBufferSize + 4 + 2); else _buffer = new Byte[14 + 125 + 125 + 8 + 10 + _options.SendBufferSize + 4 + 2]; _headerBuffer = new ArraySegment<Byte>(_buffer, 0, 14); _controlBuffer = new ArraySegment<Byte>(_buffer, 14, 125); _pongBuffer = new ArraySegment<Byte>(_buffer, 14 + 125, 125); _pingBuffer = new ArraySegment<Byte>(_buffer, 14 + 125 + 125, 8); SendBuffer = new ArraySegment<Byte>(_buffer, 14 + 125 + 125 + 8 + 10, _options.SendBufferSize); _keyBuffer = new ArraySegment<Byte>(_buffer, 14 + 125 + 125 + 8 + 10 + _options.SendBufferSize, 4); _closeBuffer = new ArraySegment<Byte>(_buffer, 14 + 125 + 125 + 8 + 10 + _options.SendBufferSize + 4, 2); _pingTimeout = _options.PingTimeout; _pingInterval = TimeSpan.FromMilliseconds(Math.Min(500, _options.PingTimeout.TotalMilliseconds / 2)); }
/// <summary> /// Disposes of the client connection, this will cause the buffers to be cleared and any outstanding streams to be /// flushed and closed /// </summary> public virtual void Dispose() { if (_Disposed) return; _Disposed = true; _Connected = false; if (_AttachedSocket != null && _AttachedSocket.Connected) _AttachedSocket.Close(); _ByteBuffer = null; if (_CurrentDataStream != null) { _CurrentDataStream.Close(); _CurrentDataStream.Dispose(); _CurrentDataStream = null; } if (_NetStream != null) { _NetStream.Close(); _NetStream.Dispose(); _NetStream = null; } _PacketsToProcess.Clear(); _PacketsToSend.Clear(); if (_UpdateThread != null) { _UpdateThread.Abort(); _UpdateThread = null; } }
public ReadEventArgs (UInt16 handle, UInt16 offset, UInt16 result, Byte[] value) { this.handle = handle; this.offset = offset; this.result = result; this.value = value; }
public void EvGv() { code = new Byte[] {0x89, 0x00}; Assert.AreEqual(code.Length, opcode.GetInstructionLengthFor(code)); encoding = opcode.GetEncodingFor(code); Assert.AreEqual(OpcodeEncoding.EvGv, encoding); }
public void GetParamsAndStart() { paramLenBuf = new Byte[4]; NetworkStream paramStream = mainSock.GetStream(); AsyncParam param = new AsyncParam(this, paramStream); paramStream.BeginRead(paramLenBuf, 0, 4, endReadParamLen, param); }
public string decodePassword(string ciper) { encodedBytes = StringToByteArray(ciper); //Convert encoded bytes back to a 'readable' string //return BitConverter.ToString(encodedBytes); return Regex.Replace(BitConverter.ToString(encodedBytes), "-", ""); }
internal StreamConnection(IReactor dispatcher, IProtocol protocol, TcpClient tcpClient, int bufferSize) : base(dispatcher, protocol) { _tcpClient = tcpClient; _readBuffer = new Byte[bufferSize]; _remoteEndPoint = _tcpClient.Client.RemoteEndPoint as IPEndPoint; }
public string EncodePassword(string originalPassword) { originalBytes = ASCIIEncoding.Default.GetBytes(originalPassword); encodedBytes = md5.ComputeHash(originalBytes); string encryptedString = ByteArrayToString(encodedBytes); return encryptedString; }
double updateRate = 4.0; // 4 updates per sec. // Use this for initialization void Start () { toggleDisplay = false; transformList = new string[] {"Hips", "LeftUpLeg", "LeftLeg", "LeftFoot", "LeftToeBase", "RightUpLeg", "RightLeg", "RightFoot", "RightToeBase", "Spine", "Spine1", "Spine2", "Spine3", "Neck", "Neck1", "Head", "LeftShoulder", "LeftArm", "LeftForeArm", "LeftHand", "RightShoulder", "RightArm", "RightForeArm", "RightHand", "root" }; foreach (string s in transformList) { GameObject o = GameObject.Find (s); if (o == null) { Debug.Log ("Could not find object: " + s); } else { objects.Add (s, o); rotationOffsets.Add ( s, Quaternion.identity ); initialOrientation.Add ( s, o.transform.localRotation ); } } data = new Byte[8192]; Connect(); }
public FileUploadResponseDto(String fileName, String contentType, Byte[] fileBuffer) : base() { _fileName = fileName; _contentType = contentType; _fileBuffer = fileBuffer; }
public void InitData(Byte[] data) { this.Data = data; this.totalLength = data.Length; this.remaining = data.Length; this.usered = 0; }
/// <summary> /// Konstruktor za inicijaliziranje BEREncoding /// objekta sa kodom... /// </summary> /// <param name="kod"></param> public BEREncoding(Byte[] kod) { this.EncodedOctets = kod; encQ = true; this.Decode(); }
public Ping() { this.InitializeComponent(); this.DoUpdateForm = this.UpdateForm; // Create a buffer of 32 bytes of data to be transmitted. this.buffer = Encoding.ASCII.GetBytes(new String('.', 32)); // Jump though 50 routing nodes tops, and don't fragment the packet this.packetOptions = new PingOptions(50, true); this.InitializeGraph(); this.dataGridView1.SuspendLayout(); this.dataGridView1.Columns.Add("1", "Count"); this.dataGridView1.Columns.Add("2", "Status"); this.dataGridView1.Columns.Add("3", "Host name"); this.dataGridView1.Columns.Add("4", "Destination"); this.dataGridView1.Columns.Add("5", "Bytes"); this.dataGridView1.Columns.Add("6", "Time to live"); this.dataGridView1.Columns.Add("7", "Roundtrip time"); this.dataGridView1.Columns.Add("8", "Time"); this.dataGridView1.ResumeLayout(true); }
public static void setupBufs() { buf2 = new Byte[19]; buf3 = new Byte[8]; buf2[0] = 33; //extension introducer buf2[1] = 255; //application extension buf2[2] = 11; //size of block buf2[3] = 78; //N buf2[4] = 69; //E buf2[5] = 84; //T buf2[6] = 83; //S buf2[7] = 67; //C buf2[8] = 65; //A buf2[9] = 80; //P buf2[10] = 69; //E buf2[11] = 50; //2 buf2[12] = 46; //. buf2[13] = 48; //0 buf2[14] = 3; //Size of block buf2[15] = 1; // buf2[16] = 0; // buf2[17] = 0; // buf2[18] = 0; //Block terminator buf3[0] = 33; //Extension introducer buf3[1] = 249; //Graphic control extension buf3[2] = 4; //Size of block buf3[3] = 9; //Flags: reserved, disposal method, user input, transparent color //buf3[4] = 10; //Delay time low byte //buf3[5] = 3; //Delay time high byte buf3[4] = 30; //Delay time low byte buf3[5] = 0; //Delay time high byte buf3[6] = 255; //Transparent color index buf3[7] = 0; //Block terminator }
public void Blanquear() { txtdescripcion.Text = string.Empty; txtcodigo.Text = string.Empty; vmContenidoFile = null; txtnombrearchivo.Text = string.Empty; }
public HTTPContext(HTTPHeader myRequestHeader, Byte[] myRequestBody, HTTPHeader myResponseHeader, Stream myResponseStream) { _RequestHeader = myRequestHeader; _RequestBody = myRequestBody; _ResponseHeader = myResponseHeader; _ResponseStream = myResponseStream; }
// ----- Private Methods ----- private static void ResetVariables() { m_thread = null; m_stop = false; m_pars = null; m_containingBytes = null; }
/// <summary> /// Sets the data of ColorVideo. /// </summary> /// <param name="sender"></param> /// <param name="colorImageFrame"></param> public void KinectColorFrameReady(object sender, ColorImageFrameReadyEventArgs colorImageFrame) { //Get raw image ColorVideoFrame = colorImageFrame.OpenColorImageFrame(); if (ColorVideoFrame != null) { //Create array for pixel data and copy it from the image frame PixelData = new Byte[ColorVideoFrame.PixelDataLength]; ColorVideoFrame.CopyPixelDataTo(PixelData); //Convert RGBA to BGRA, Kinect and XNA uses different color-formats. BgraPixelData = new Byte[ColorVideoFrame.PixelDataLength]; for (int i = 0; i < PixelData.Length; i += 4) { BgraPixelData[i] = PixelData[i + 2]; BgraPixelData[i + 1] = PixelData[i + 1]; BgraPixelData[i + 2] = PixelData[i]; BgraPixelData[i + 3] = (Byte)255; //The video comes with 0 alpha so it is transparent } // Create a texture and assign the realigned pixels ColorVideo = new Texture2D(Graphics.GraphicsDevice, ColorVideoFrame.Width, ColorVideoFrame.Height); ColorVideo.SetData(BgraPixelData); ColorVideoFrame.Dispose(); } }