Marco Hajek

Marco Hajek

  • NA
  • 1
  • 1.2k

Php Code to C# Help

Jun 18 2014 7:47 PM
Hey Guys...
I need help... I wrote a little Guide for my Minecraft Server. On my Homepage i can read out the Slots and Message of the Day of my running server. But i got no Idea how i could do this in C#.
I hope you can help me...
 
Here is the php Code:
 
<?php
function fetch_server_info($ip, $port)
{
$socket = @fsockopen($ip, $port, $errno, $errstr, 1);
if ($socket == false)
{
return false;
}
fwrite($socket, "\xfe");
$data = fread($socket, 256);
if (substr($data, 0, 1) != "\xff")
{
return false;
}
$data = explode('§', mb_convert_encoding(substr($data, 3), 'UTF8', 'UCS-2'));
return array(
'motd' => $data[0],
'players' => intval($data[1]),
'max_players' => intval($data[2])
);
}
?>