Send and receive binary data over web sockets in Javascript?

The next draft (hybi-07) of the WebSockets specification is being implemented in most browsers and it will add built-in binary support to the protocol and API. However, until then, WebSockets payload is encoded as UTF-8. In order to send binary data you must use some way of encoding the binary data as UTF-8. There are … Read more

Convert a binary string representation to a byte array

In case you don’t have this LINQ fetish, so common lately, you can try the normal way string input …. int numOfBytes = input.Length / 8; byte[] bytes = new byte[numOfBytes]; for(int i = 0; i < numOfBytes; ++i) { bytes[i] = Convert.ToByte(input.Substring(8 * i, 8), 2); } File.WriteAllBytes(fileName, bytes); LINQ is great but there … Read more

Python 2.x – Write binary output to stdout?

Which platform are you on? You could try this recipe if you’re on Windows (the link suggests it’s Windows specific anyway). if sys.platform == “win32”: import os, msvcrt msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) There are some references on the web that there would/should be a function in Python 3.1 to reopen sys.stdout in binary mode but I don’t … Read more

Binary grep on Linux?

This seems to work for me: grep –only-matching –byte-offset –binary –text –perl-regexp “<\x-hex pattern>” <file> Short form: grep -obUaP “<\x-hex pattern>” <file> Example: grep -obUaP “\x01\x02” /bin/grep Output (Cygwin binary): 153: <\x01\x02> 33210: <\x01\x02> 53453: <\x01\x02> So you can grep this again to extract offsets. But don’t forget to use binary mode again.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)