Все вопросы: [byte]

107 вопросов

1
голосов
1ответов
945 просмотров

Sending part of byte array over the network using WCF

I have a byte array of some binary data that i need to send over the network using WCF and NetTcpBinding. My problem is that i need to send only the part of the array. Is there any way to do this, other than copying that part to a separate array, and sending that one. This extra copying degrades ...

0
голосов
5ответов
2496 просмотров

Confusing type conversion - 2 Bytes to Double

I was recently asked to take over a project in which waveform data is sampled from a power converter and sent to an intelligent agent where calculations are done and the appropriate actions are taken based on the results. The following (java)snippet is what the previous coder used to convert t...

1
голосов
3ответов
4303 просмотров

Read bytes from string as floats

I've got a python webserver where small binary files are POST:ed. The posted data is represented as strings. I want to examine the contents of these strings. But to do that, I need to convert each 4 bytes to floats (little endian). How do you do that?

8
голосов
4ответов
4074 просмотров

Using JavaScript to truncate text to a certain size (8 KB)

I'm using the Zemanta API, which accepts up to 8 KB of text per call. I'm extracting the text to send to Zemanta from Web pages using JavaScript, so I'm looking for a function that will truncate my text at exactly 8 KB. Zemanta should do this truncation on its own (i.e., if you send it a larger ...

6
голосов
2ответов
2868 просмотров

PHP - determine how many bytes sent over http

Is it possible in PHP to get a count of the number of bytes transmitted to the client? For example, if I'm outputting a 10 MB file, is there a way to find out if all 10 MB were sent to the client, or to see if the client interrupted the transfer partway? I know Apache will log this afterwards, bu...

36
голосов
4ответов
24324 просмотров

Searching for a sequence of Bytes in a Binary File with Java

I have a sequence of bytes that I have to search for in a set of Binary files using Java. Example: I'm searching for the byte sequence DEADBEEF (in hex) in a Binary file. How would I go about doing this in Java? Is there a built-in method, like String.contains() for Binary files?

1
голосов
4ответов
8846 просмотров

c++ how to add a zero bits byte or null to a string

I am doing a simple client implementation of TFTP. Here i need to send read request in following format /* send request 2 bytes string 1 byte string 1 byte ------------------------------------------------------ RRQ/ | 01/02 | Filename | 0 | Mode | 0 | WRQ ---...

2
голосов
3ответов
5328 просмотров

What is the byte signature of a password-protected ZIP file?

I've read that ZIP files start with the following bytes: 50 4B 03 04 Reference: http://www.garykessler.net/library/file_sigs.html Question: Is there a certain sequence of bytes that indicate a ZIP file has been password-protected?

2
голосов
1ответов
679 просмотров

Comparing two files

I am comparing two files by reading them into filestream and comparing byte by byte. How can I skip whitespaces while comparing? I am using C#.net

10
голосов
3ответов
32765 просмотров

Convert a hex string to a byte in Java

In Java, how can a hexadecimal string representation of a byte (e.g. "1e") be converted into a byte value? For example: byte b = ConvertHexStringToByte("1e");

1
голосов
2ответов
2150 просмотров

Counting Bytes sent/received over HTTP

In Java, How could the bytes sent and received over an active HTTP connection be counted? I want to display some statistics like: Bytes Sent : xxxx Kb Bytes Received : xxxx Kb Duration : hh:mm

9
голосов
5ответов
32097 просмотров

Good way to convert between short and bytes?

I need to take pairs of bytes in, and output shorts, and take shorts in and output pairs of bytes. Here are the functions i've devised for such a purpose: static short ToShort(short byte1, short byte2) { short number = (short)byte2; number <<= 4; number += (short)byte1; ret...

0
голосов
2ответов
1368 просмотров

how to convert byte[] to an ArrayList of Hashtables?

Could someone please give me an example on how can I convert a byte[] to an ArrayList of Hashtables with C# ? (the byte[] represents the ArrayList of Hashtables that was previously serialized) Note: I'm running under Windows Mobile, which does not provide BinaryFormatter.

4
голосов
4ответов
6407 просмотров

byte[] to ArrayList?

Could somebody tell me how can I convert byte[] to ArrayList by using C# under Windows Mobile? Later edit: this would go like having an ArrayList containing instances of a custom type. This list goes to a database (into a blob) as a byte array (the conversion is done by the database API); Wha...

6
голосов
1ответов
10763 просмотров

Create UiImage from NSData

Below is code I copied (from this site) and modified only slightly since the original code would not compile. I want to manipulate the byte array for edge detection and eventually simple changes to colors, but first I wanted to get the basic code working. Currently, the system compiles and runs. ...

1
голосов
3ответов
2021 просмотров

How to handle buffering data read from the network?

When reading data over the network, you specify a buffer to receive the data into: byte[] b = new byte[4096]; socket.Receive(b); Now my first thought is of course to reuse the receive buffer by declaring it as a member variable of the class. My next issue is that I have not received all of the...

22
голосов
5ответов
17961 просмотров

String from byte array doesn't get trimmed in C#?

I have a byte array similar to this (16 bytes): 71 77 65 72 74 79 00 00 00 00 00 00 00 00 00 00 I use this to convert it to a string and trim the ending spaces: ASCIIEncoding.ASCII.GetString(data).Trim(); I get the string fine, however it still has all the ending spaces. So I get something ...

6
голосов
3ответов
5623 просмотров

Designing a BitStream in C#

I'm looking at the C# library called BitStream, which allows you to write and read any number of bits to a standard C# Stream object. I noticed what seemed to me a strange design decision: When adding bits to an empty byte, the bits are added to the MSB of the byte. For example: var s = new Bit...

1
голосов
3ответов
3162 просмотров

Convert an array of different value types to a byte array

This is what I've come up with so far, but it doesn't seem very optimal, any ideas on better approaches? public void ToBytes(object[] data, byte[] buffer) { byte[] obytes; int offset = 0; foreach (object obj in data) { if (obj is string) obytes = System.Text....

4
голосов
5ответов
23030 просмотров

Dynamic Byte Array in C# by Socket Programming [List<byte> does not work]</byte>

I'm sending to a device a request as byte array and I want to receive the anwser device gives. ... Socket deviceSocket = new Socket(server); List&lt;byte&gt; coming = new List&lt;byte&gt;(); ... deviceSocket.Receive(coming) Here the program gives error: Error 1 The best overloaded method ma...

0
голосов
3ответов
283 просмотров

Buffers and bytes?

Could someone explain to me the uses of using buffers, and perhaps some simple (documented) examples of a buffer in use. Thanks. I lack much knowledge in this area of Java programming, so forgive me if I asked the question wrong. :s

1
голосов
3ответов
394 просмотров

After reading in bytes from file, most are right except 1 is wrong and negative

In Java, I just read a file into a ByteBuffer. When I started checking to make sure that the ByteBuffer contained the right bytes, I noticed that it had mostly the correct start and end bytes, except for the 3rd byte, it has -117 instead of what emacs says should be 139 (8b in hexl-mode). What gi...

2
голосов
5ответов
1961 просмотров

Java - is it possible to read a file line by line, stop, and then immediately start reading bytes where I stopped?

I'm having an issue trying to parse the ascii part of a file, and once I hit the end tag, IMMEDIATELY start reading in the bytes from that point on. Everything I know in Java to read off a line or a whole word creates a buffer, which ruins any chance of getting the bytes immediately following my ...

9
голосов
9ответов
8283 просмотров

Quickest way (performance-wise) to turn a string into a byte[] array in C# using the ASCII character encoding

What's the fastest way to turn a string into a byte[] array in C#? I'm sending tonnes of string data through sockets and need to optimize every single operation. Currently I transform the strings in to byte[] arrays before sending using: private static readonly Encoding encoding = new ASCIIEnc...

0
голосов
5ответов
7064 просмотров

Writing a 2-byte integer to a stream?

I'm trying to interact with an application over the network which uses a simple protocol. I have to send a header that looks like this: 2 bytes = Data Length (including Request Type) 1 byte = Request Type I'm taking both parameters as integers: private static void WriteHeader(Stream buf, int l...

13
голосов
4ответов
25232 просмотров

Python - How to edit hexadecimal file byte by byte

I want to be able to open up an image file and extra the hexadecimal values byte-by-byte. I have no idea how to do this and googling "python byte editing" and "python byte array" didn't come up with anything, surprisingly. Can someone point me towards the library i need to use, specific methods i...

35
голосов
1ответов
29087 просмотров

Download a file over HTTP into a byte array in C#?

I'm trying to read a file that I have a web address for into a byte array. I've been using File.ReadAllBytes to read files locally and I've been unable to figure out the cleanest way to do this for a file on the web. I imagine this is just a quick snippet of code, but everything I can find th...

1
голосов
3ответов
7051 просмотров

C++ byte stream

For a networked application, the way we have been transmitting dynamic data is through memcpying a struct into a (void*). This poses some problems, like when this is done to an std::string. Strings can be dynamic length, so how will the other side know when the string ends? An idea I had was to u...

3
голосов
3ответов
2182 просмотров

How to read a single BIT in an Array of Bytes?

The problem is that I have an Array of Byte with 200 Indexes and just want to check that is the Fourth bit of MyArray[75] is Zero(0) or One(1). byte[] MyArray; //with 200 elements //check the fourth BIT of MyArray[75]

0
голосов
3ответов
930 просмотров

char array assignment and management

I'm supposed to write a library in c++ that should handle the connections to the kad network. I'm trying to build a packet accordant to those used by aMule&amp;co. And I really can't understand the difference between this code: buffer = "\xe4\x20\x02"; and, for example, this code: char p_buf...