0

わかりましたので、パケットをMinecraftサーバーに送信するこのプログラムに取り組んでおり、その代わりにサーバーに関する情報が提供されます;(今日のメッセージ、オンラインのプレーヤー、最大プレーヤー)

問題は応答が UCS-2 にあることです

したがって、パケットをサーバーに送信し、応答をバイト単位で取得すると。それを使用できるように、それを ascii に変換するにはどうすればよいですか?

これまでの私のコードは次のとおりです

Dim client As New System.Net.Sockets.TcpClient()
client .Connect("178.33.213.54", 25565)

Dim stream As NetworkStream = client .GetStream



'Send Bytes
Dim sendBytes As [Byte]() = {&HFE}
stream.Write(sendBytes, 0, sendBytes.Length)

'Receive Bytes
Dim bytes(client .ReceiveBufferSize) As Byte
stream.Read(bytes, 0, CInt(leclient.ReceiveBufferSize))

'Convert it to ASCII
....


'Output it to Console
....

これは、PHP、python、および ruby​​ での同じコードです。


php -> https://gist.github.com/1235274


python -> https://gist.github.com/1209061


ルビー -> http://pastebin.com/q5zFPcXV

ドキュメントはこちら: http://www.wiki.vg/Protocol#Server_List_Ping_.280xFE.29

前もって感謝します!
ヴィドゥ

4

1 に答える 1

2

テスト済みで動作しています。

Dim client As New System.Net.Sockets.TcpClient()

client.Connect("178.33.213.54", 25565)

Dim stream As System.Net.Sockets.NetworkStream = client.GetStream

'Send Bytes
Dim sendBytes As [Byte]() = {&HFE}
stream.Write(sendBytes, 0, sendBytes.Length)

''Receive Bytes
Dim bytes(client.ReceiveBufferSize) As Byte
stream.Read(bytes, 0, CInt(client.ReceiveBufferSize))

Dim sb As New System.Text.StringBuilder
For i As Integer = 3 To bytes.GetUpperBound(0) Step 2
  Dim byt2(1) As Byte
  byt2(0) = bytes(i + 1)
  byt2(1) = bytes(i)

  Dim ii As Integer = BitConverter.ToInt16(byt2, 0)
  'sb.Append(Hex(ii)) 'debug
  sb.Append(ChrW(ii))
Next i
MsgBox(sb.ToString)
stream.Close()
于 2012-10-04T02:13:30.863 に答える