$$Excel-Macros$$ need help to convert this code into excel macro

2014-11-27 Thread my excel
sir, this code from bahri in c# php something
sir pls help convert it to excel macro
thank you





GSM LAC/CID -> loc test



body {
font-family: Verdana, Helvetica, Geneva, Arial,
  SunSans-Regular, sans-serif;
font-size:12;
}
td {
font-family: Verdana, Helvetica, Geneva, Arial,
  SunSans-Regular, sans-serif;
font-size:12;
}









http://en.wikipedia.org/wiki/List_of_mobile_country_codes";>MCC
- Mobile Country Code

">


http://en.wikipedia.org/wiki/Mobile_Network_Code";>MNC - Mobile
Network Code

">


LAC - Location Area Code

">


CID - Cell ID

">







 65535);
if ($is_umts_cell) // GSM: 4 hex digits, UTMS: 6 hex digits
$data[0x1c] = 5;
else
$data[0x1c] = 3;

$hexmcc = substr("".dechex($_REQUEST["mcc"]),-8);
$hexmnc = substr("".dechex($_REQUEST["mnc"]),-8);
$hexlac = substr("".dechex($_REQUEST["lac"]),-8);
$hexcid = substr("".dechex($_REQUEST["cid"]),-8);

echo "MCC=$hexmcc MNC=$hexmnc LAC=$hexlac CID=$hexcid";
 $data[0x11] = pack("H*",substr($hexmnc,0,2));
$data[0x12] = pack("H*",substr($hexmnc,2,2));
$data[0x13] = pack("H*",substr($hexmnc,4,2));
$data[0x14] = pack("H*",substr($hexmnc,6,2));

$data[0x15] = pack("H*",substr($hexmcc,0,2));
$data[0x16] = pack("H*",substr($hexmcc,2,2));
$data[0x17] = pack("H*",substr($hexmcc,4,2));
$data[0x18] = pack("H*",substr($hexmcc,6,2));
 $data[0x27] = pack("H*",substr($hexmnc,0,2));
$data[0x28] = pack("H*",substr($hexmnc,2,2));
$data[0x29] = pack("H*",substr($hexmnc,4,2));
$data[0x2a] = pack("H*",substr($hexmnc,6,2));

$data[0x2b] = pack("H*",substr($hexmcc,0,2));
$data[0x2c] = pack("H*",substr($hexmcc,2,2));
$data[0x2d] = pack("H*",substr($hexmcc,4,2));
$data[0x2e] = pack("H*",substr($hexmcc,6,2));

$data[0x1f] = pack("H*",substr($hexcid,0,2));
$data[0x20] = pack("H*",substr($hexcid,2,2));
$data[0x21] = pack("H*",substr($hexcid,4,2));
$data[0x22] = pack("H*",substr($hexcid,6,2));

$data[0x23] = pack("H*",substr($hexlac,0,2));
$data[0x24] = pack("H*",substr($hexlac,2,2));
$data[0x25] = pack("H*",substr($hexlac,4,2));
$data[0x26] = pack("H*",substr($hexlac,6,2));

/* I used file_get_contents() at my laptop webserver, but it seems like the
PHP version
 * at my hosting company is old and it is not supporting that.
 * For the hosting company, here we're using cURL.
 */
$use_curl = true;
if ($use_curl) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.google.com/glm/mmap";);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-type:
application/binary"));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_POST, 1);
$response = curl_exec($ch);
if (curl_errno($ch))
exit("Error: Failed to post data $str curl_errno($ch)");

$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$str = substr($response, $header_size);

curl_close($ch);
} else {
$context = array (
'http' => array (
'method' => 'POST',
'header'=> "Content-type: application/binary\r\n"
. "Content-Length: " . strlen($data) . "\r\n",
'content' => $data
)
);
$xcontext = stream_context_create($context);
$str=file_get_contents("http://www.google.com/glm/mmap";, FALSE, $xcontext);
}
 $opcode1 = ((ord($str[0]) << 8)) | ord($str[1]);
$opcode2 = ord($str[2]);

if (($opcode1 != 0x0e) || ($opcode2 != 0x1b))
exit("Error: Invalid opcode $opcode1 $opcode2. Maybe the LAC/CID is
invalid");

$retcode = ((ord($str[3]) << 24) | (ord($str[4]) << 16) | (ord($str[5]) <<
8) | (ord($str[6])));
if ($retcode != 0)
exit("Error: Invalid return code $retcode. Maybe the LAC/CID is
invalid");

$lat = ((ord($str[7]) << 24) | (ord($str[8]) << 16) | (ord($str[9]) << 8) |
(ord($str[10]))) / 100;
$lon = ((ord($str[11]) << 24) | (ord($str[12]) << 16) | (ord($str[13]) <<
8) | (ord($str[14]))) / 100;

// exit script if cannot geocode cell e.g. not on google's database
if ($lat == 0 and $lon == 0)
exit('ERROR: cannot determine cell tower location from cell LAC: ' .
$_REQUEST["lac"] . ', ' . 'CID: ' . $_REQUEST["cid"]);

$addr = $lat . ',' . $lon;
$t = urlencode(" (MCC=$mcc MNC=$mnc LAC=$lac CID=$cid)");
echo "Lat=$lat Lon=$lon";
}
?>


http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=&ie=UTF8&ll=&sll=&t=h&z=12&output=embed">

 
 

Prince Daya

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't eve

Re: $$Excel-Macros$$ need help to convert this code into excel macro

2014-12-01 Thread my excel
hi experts pls convert to vba macro

mmc input text box
mnc input text box
lac input text box
cid input text box
button

below code








http://en.wikipedia.org/wiki/List_of_mobile_country_codes";>MCC
- Mobile Country Code

">


http://en.wikipedia.org/wiki/Mobile_Network_Code";>MNC - Mobile
Network Code

">


LAC - Location Area Code

">


CID - Cell ID

">







 65535);
if ($is_umts_cell) // GSM: 4 hex digits, UTMS: 6 hex digits
$data[0x1c] = 5;
else
$data[0x1c] = 3;

$hexmcc = substr("".dechex($_REQUEST["mcc"]),-8);
$hexmnc = substr("".dechex($_REQUEST["mnc"]),-8);
$hexlac = substr("".dechex($_REQUEST["lac"]),-8);
$hexcid = substr("".dechex($_REQUEST["cid"]),-8);

echo "MCC=$hexmcc MNC=$hexmnc LAC=$hexlac CID=$hexcid";
 $data[0x11] = pack("H*",substr($hexmnc,0,2));
$data[0x12] = pack("H*",substr($hexmnc,2,2));
$data[0x13] = pack("H*",substr($hexmnc,4,2));
$data[0x14] = pack("H*",substr($hexmnc,6,2));

$data[0x15] = pack("H*",substr($hexmcc,0,2));
$data[0x16] = pack("H*",substr($hexmcc,2,2));
$data[0x17] = pack("H*",substr($hexmcc,4,2));
$data[0x18] = pack("H*",substr($hexmcc,6,2));
 $data[0x27] = pack("H*",substr($hexmnc,0,2));
$data[0x28] = pack("H*",substr($hexmnc,2,2));
$data[0x29] = pack("H*",substr($hexmnc,4,2));
$data[0x2a] = pack("H*",substr($hexmnc,6,2));

$data[0x2b] = pack("H*",substr($hexmcc,0,2));
$data[0x2c] = pack("H*",substr($hexmcc,2,2));
$data[0x2d] = pack("H*",substr($hexmcc,4,2));
$data[0x2e] = pack("H*",substr($hexmcc,6,2));

$data[0x1f] = pack("H*",substr($hexcid,0,2));
$data[0x20] = pack("H*",substr($hexcid,2,2));
$data[0x21] = pack("H*",substr($hexcid,4,2));
$data[0x22] = pack("H*",substr($hexcid,6,2));

$data[0x23] = pack("H*",substr($hexlac,0,2));
$data[0x24] = pack("H*",substr($hexlac,2,2));
$data[0x25] = pack("H*",substr($hexlac,4,2));
$data[0x26] = pack("H*",substr($hexlac,6,2));

/* I used file_get_contents() at my laptop webserver, but it seems like the
PHP version
 * at my hosting company is old and it is not supporting that.
 * For the hosting company, here we're using cURL.
 */
$use_curl = true;
if ($use_curl) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.google.com/glm/mmap";);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-type:
application/binary"));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_POST, 1);
$response = curl_exec($ch);
if (curl_errno($ch))
exit("Error: Failed to post data $str curl_errno($ch)");

$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$str = substr($response, $header_size);

curl_close($ch);
} else {
$context = array (
'http' => array (
'method' => 'POST',
'header'=> "Content-type: application/binary\r\n"
. "Content-Length: " . strlen($data) . "\r\n",
'content' => $data
)
);
$xcontext = stream_context_create($context);
$str=file_get_contents("http://www.google.com/glm/mmap";, FALSE, $xcontext);
}
 $opcode1 = ((ord($str[0]) << 8)) | ord($str[1]);
$opcode2 = ord($str[2]);

if (($opcode1 != 0x0e) || ($opcode2 != 0x1b))
exit("Error: Invalid opcode $opcode1 $opcode2. Maybe the LAC/CID is
invalid");

$retcode = ((ord($str[3]) << 24) | (ord($str[4]) << 16) | (ord($str[5]) <<
8) | (ord($str[6])));
if ($retcode != 0)
exit("Error: Invalid return code $retcode. Maybe the LAC/CID is
invalid");

$lat = ((ord($str[7]) << 24) | (ord($str[8]) << 16) | (ord($str[9]) << 8) |
(ord($str[10]))) / 100;
$lon = ((ord($str[11]) << 24) | (ord($str[12]) << 16) | (ord($str[13]) <<
8) | (ord($str[14]))) / 100;

// exit script if cannot geocode cell e.g. not on google's database
if ($lat == 0 and $lon == 0)
exit('ERROR: cannot determine cell tower location from cell LAC: ' .
$_REQUEST["lac"] . ', ' . 'CID: ' . $_REQUEST["cid"]);

$addr = $lat . ',' . $lon;
$t = urlencode(" (MCC=$mcc MNC=$mnc LAC=$lac CID=$cid)");
echo "Lat=$lat Lon=$lon";
}
?>


http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=&ie=UTF8&ll=&sll=&t=h&z=12&output=embed">

 
 



On Fri, Nov 28, 2014 at 12:09 PM, my excel  wrote:

> sir, this code from bahri in c# php something
> sir pls help convert it to excel macro
> thank you
>
>
>
> 
> 
> GSM LAC/CID -> loc test
> 
> 
> 
> body {
> font-family: Verdana, Helvetica, Geneva, Arial,
>   SunSans-Regular, sans-serif;
> font-size:12;
> }
> td {
> font-family: Verdana, Helvetica, Geneva, Arial,
>   SunSans-Regular, sans-serif;
> font-size:12;
> }
> 
> 
> 
> 
> 
> 
> 
> 
> 
> http://en.wikipedia.org/wiki/List_of_mobile_country_codes";>MCC
> - Mobile Country Code
> 
> ">
> 
> 
> http://en.wikipedia.org/wiki/Mobile_Network_Code";>MNC -
> Mobile Network Code
> 
> ">
> 
> 
> LAC - Location Area Code
> 
> ">
> 
> 
> CID - Cell ID
> 
> ">
> 
> 
> 
> 
> 
> 
> 
>  if (isset($lac) && isset($cid) && isset($mnc) && isset($mcc)) {
> $data =
> "\x00\x0e".
> "\x00\x00\x00\x00\x0

Re: $$Excel-Macros$$ need help to convert this code into excel macro

2014-12-01 Thread Vaibhav Joshi
Hi

pl share us code in proper html file format instead of this code..


+
*I did not do this for you. God is here working through me for you.*

On Mon, Dec 1, 2014 at 1:36 PM, my excel  wrote:

> hi experts pls convert to vba macro
>
> mmc input text box
> mnc input text box
> lac input text box
> cid input text box
> button
>
> below code
>
> 
> 
> 
> 
> 
> 
> 
> http://en.wikipedia.org/wiki/List_of_mobile_country_codes";>MCC
> - Mobile Country Code
> 
> ">
> 
> 
> http://en.wikipedia.org/wiki/Mobile_Network_Code";>MNC -
> Mobile Network Code
> 
> ">
> 
> 
> LAC - Location Area Code
> 
> ">
> 
> 
> CID - Cell ID
> 
> ">
> 
> 
> 
> 
> 
> 
> 
>  if (isset($lac) && isset($cid) && isset($mnc) && isset($mcc)) {
> $data =
> "\x00\x0e".
> "\x00\x00\x00\x00\x00\x00\x00\x00".
> "\x00\x00".
> "\x00\x00".
> "\x00\x00".
> "\x1b".
> "\x00\x00\x00\x00".
> "\x00\x00\x00\x00".
> "\x00\x00\x00\x00".
> "\x00\x00".
> "\x00\x00\x00\x00".
> "\x00\x00\x00\x00".
> "\x00\x00\x00\x00".
> "\x00\x00\x00\x00".
> "\xff\xff\xff\xff".
> "\x00\x00\x00\x00";
>
> $is_umts_cell = ($cid > 65535);
> if ($is_umts_cell) // GSM: 4 hex digits, UTMS: 6 hex digits
> $data[0x1c] = 5;
> else
> $data[0x1c] = 3;
>
> $hexmcc = substr("".dechex($_REQUEST["mcc"]),-8);
> $hexmnc = substr("".dechex($_REQUEST["mnc"]),-8);
> $hexlac = substr("".dechex($_REQUEST["lac"]),-8);
> $hexcid = substr("".dechex($_REQUEST["cid"]),-8);
>
> echo "MCC=$hexmcc MNC=$hexmnc LAC=$hexlac CID=$hexcid";
>  $data[0x11] = pack("H*",substr($hexmnc,0,2));
> $data[0x12] = pack("H*",substr($hexmnc,2,2));
> $data[0x13] = pack("H*",substr($hexmnc,4,2));
> $data[0x14] = pack("H*",substr($hexmnc,6,2));
>
> $data[0x15] = pack("H*",substr($hexmcc,0,2));
> $data[0x16] = pack("H*",substr($hexmcc,2,2));
> $data[0x17] = pack("H*",substr($hexmcc,4,2));
> $data[0x18] = pack("H*",substr($hexmcc,6,2));
>  $data[0x27] = pack("H*",substr($hexmnc,0,2));
> $data[0x28] = pack("H*",substr($hexmnc,2,2));
> $data[0x29] = pack("H*",substr($hexmnc,4,2));
> $data[0x2a] = pack("H*",substr($hexmnc,6,2));
>
> $data[0x2b] = pack("H*",substr($hexmcc,0,2));
> $data[0x2c] = pack("H*",substr($hexmcc,2,2));
> $data[0x2d] = pack("H*",substr($hexmcc,4,2));
> $data[0x2e] = pack("H*",substr($hexmcc,6,2));
>
> $data[0x1f] = pack("H*",substr($hexcid,0,2));
> $data[0x20] = pack("H*",substr($hexcid,2,2));
> $data[0x21] = pack("H*",substr($hexcid,4,2));
> $data[0x22] = pack("H*",substr($hexcid,6,2));
>
> $data[0x23] = pack("H*",substr($hexlac,0,2));
> $data[0x24] = pack("H*",substr($hexlac,2,2));
> $data[0x25] = pack("H*",substr($hexlac,4,2));
> $data[0x26] = pack("H*",substr($hexlac,6,2));
>
> /* I used file_get_contents() at my laptop webserver, but it seems like
> the PHP version
>  * at my hosting company is old and it is not supporting that.
>  * For the hosting company, here we're using cURL.
>  */
> $use_curl = true;
> if ($use_curl) {
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_URL, "http://www.google.com/glm/mmap";);
> curl_setopt($ch, CURLOPT_HEADER, true);
> curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
> curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
> curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-type:
> application/binary"));
> curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
> curl_setopt($ch, CURLOPT_POST, 1);
> $response = curl_exec($ch);
> if (curl_errno($ch))
> exit("Error: Failed to post data $str curl_errno($ch)");
>
> $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
> $str = substr($response, $header_size);
>
> curl_close($ch);
> } else {
> $context = array (
> 'http' => array (
> 'method' => 'POST',
> 'header'=> "Content-type: application/binary\r\n"
> . "Content-Length: " . strlen($data) . "\r\n",
> 'content' => $data
> )
> );
> $xcontext = stream_context_create($context);
> $str=file_get_contents("http://www.google.com/glm/mmap";, FALSE,
> $xcontext);
> }
>  $opcode1 = ((ord($str[0]) << 8)) | ord($str[1]);
> $opcode2 = ord($str[2]);
>
> if (($opcode1 != 0x0e) || ($opcode2 != 0x1b))
> exit("Error: Invalid opcode $opcode1 $opcode2. Maybe the LAC/CID is
> invalid");
>
> $retcode = ((ord($str[3]) << 24) | (ord($str[4]) << 16) | (ord($str[5]) <<
> 8) | (ord($str[6])));
> if ($retcode != 0)
> exit("Error: Invalid return code $retcode. Maybe the LAC/CID is
> invalid");
>
> $lat = ((ord($str[7]) << 24) | (ord($str[8]) << 16) | (ord($str[9]) << 8)
> | (ord($str[10]))) / 100;
> $lon = ((ord($str[11]) << 24) | (ord($str[12]) << 16) | (ord($str[13]) <<
> 8) | (ord($str[14]))) / 100;
>
> // exit script if cannot geocode cell e.g. not on google's database
> if ($lat == 0 and $lon == 0)
> exit('ERROR: cannot determine cell tower location from cell LAC: ' .
> $_REQUEST["lac"] .

Re: $$Excel-Macros$$ need help to convert this code into excel macro

2014-12-01 Thread my excel
Guruji,
please send to my email id only & html & php in attached file
it's my request

thank you

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
using System.Diagnostics;

/*
* Sample code to obtain geo codes from a cell info
* "GSM/UMTS" setting revealed by smuraro, thanks!
*/

namespace GMM {
class Program {
static byte[] PostData(int MCC, int MNC, int LAC, int CID, bool
shortCID) {
/* The shortCID parameter follows heuristic experiences:
 * Sometimes UMTS CIDs are build up from the original GSM CID
(lower 4 hex digits)
 * and the RNC-ID left shifted into the upper 4 digits.
 */
byte[] pd = new byte[] {
0x00, 0x0e,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,

0x1b,
0x00, 0x00, 0x00, 0x00, // Offset 0x11
0x00, 0x00, 0x00, 0x00, // Offset 0x15
0x00, 0x00, 0x00, 0x00, // Offset 0x19
0x00, 0x00,
0x00, 0x00, 0x00, 0x00, // Offset 0x1f
0x00, 0x00, 0x00, 0x00, // Offset 0x23
0x00, 0x00, 0x00, 0x00, // Offset 0x27
0x00, 0x00, 0x00, 0x00, // Offset 0x2b
0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00
};

bool isUMTSCell = ((Int64)CID > 65535);

if (isUMTSCell)
Console.WriteLine("UMTS CID. {0}", shortCID ? "Using short
CID to resolve." : "");
else
Console.WriteLine("GSM CID given.");

if (shortCID)
CID &= 0x;  /* Attempt to resolve the cell using
the GSM CID part */

if ((Int64)CID > 65536) /* GSM: 4 hex digits, UTMS: 6 hex
digits */
pd[0x1c] = 5;
else
pd[0x1c] = 3;

pd[0x11] = (byte)((MNC >> 24) & 0xFF);
pd[0x12] = (byte)((MNC >> 16) & 0xFF);
pd[0x13] = (byte)((MNC >> 8) & 0xFF);
pd[0x14] = (byte)((MNC >> 0) & 0xFF);

pd[0x15] = (byte)((MCC >> 24) & 0xFF);
pd[0x16] = (byte)((MCC >> 16) & 0xFF);
pd[0x17] = (byte)((MCC >> 8) & 0xFF);
pd[0x18] = (byte)((MCC >> 0) & 0xFF);

pd[0x27] = (byte)((MNC >> 24) & 0xFF);
pd[0x28] = (byte)((MNC >> 16) & 0xFF);
pd[0x29] = (byte)((MNC >> 8) & 0xFF);
pd[0x2a] = (byte)((MNC >> 0) & 0xFF);

pd[0x2b] = (byte)((MCC >> 24) & 0xFF);
pd[0x2c] = (byte)((MCC >> 16) & 0xFF);
pd[0x2d] = (byte)((MCC >> 8) & 0xFF);
pd[0x2e] = (byte)((MCC >> 0) & 0xFF);

pd[0x1f] = (byte)((CID >> 24) & 0xFF);
pd[0x20] = (byte)((CID >> 16) & 0xFF);
pd[0x21] = (byte)((CID >> 8) & 0xFF);
pd[0x22] = (byte)((CID >> 0) & 0xFF);

pd[0x23] = (byte)((LAC >> 24) & 0xFF);
pd[0x24] = (byte)((LAC >> 16) & 0xFF);
pd[0x25] = (byte)((LAC >> 8) & 0xFF);
pd[0x26] = (byte)((LAC >> 0) & 0xFF);

return pd;
}

static void Main(string[] args) {

if (args.Length < 4) {
Console.WriteLine("Usage: gmm MCC MNC LAC CID
[\"shortcid\"]");
return;
}
string shortCID = "";   /* Default, no change at all */
if (args.Length == 5)
 shortCID = args[4].ToLower();

try {
String url = "http://www.google.com/glm/mmap";;
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(new
Uri(url));
req.Method = "POST";

int MCC = Convert.ToInt32(args[0]);
int MNC = Convert.ToInt32(args[1]);
int LAC = Convert.ToInt32(args[2]);
int CID = Convert.ToInt32(args[3]);
byte[] pd = PostData(MCC, MNC, LAC, CID, shortCID ==
"shortcid");

req.ContentLength = pd.Length;
req.ContentType = "application/binary";
Stream outputStream = req.GetRequestStream();
outputStream.Write(pd, 0, pd.Length);
outputStream.Close();

HttpWebResponse res = (HttpWebResponse)req.GetResponse();
byte[] ps = new byte[res.ContentLength];
int totalBytesRead = 0;
while (totalBytesRead < ps.Length) {
totalBytesRead += res.GetResponseStream().Read(ps,
totalBytesRead, ps.Length - totalBytesRead);
}

if (res.StatusCode == HttpStatusCode.OK) {
short opcode1 = (short)(ps[0] << 8 | ps[1]);
byte opcode2 = ps[2];
System.Diagnostics.Debug.Assert(opcode1 == 0x0e);
System.Diagnostics.Debug.Assert(opcode2 == 0x1b);