0
Reply

Php Code to C# Help

Marco Hajek

Marco Hajek

Jun 18 2014 7:47 PM
703
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])
);
}
?>
 

Next Recommended Forum