Im trying to query a HL2 master server that contains the list of servers.
Here is the protocol: http://developer.valvesoftware.com/wiki/Master_Server_Query_Protocol
and here is my code
Now, I know the server replies, SocketReadAvail returns I think 1428 for me but when I try to read, with ReadByte I get "Error reading from stream."
Can anyone help me?
Here is the protocol: http://developer.valvesoftware.com/wiki/Master_Server_Query_Protocol
and here is my code
SuperStrict Framework brl.blitz Import brl.retro Import brl.socket Global Socket:TSocket=CreateUDPSocket() Global Stream:TStream=CreateSocketStream(Socket) BindSocket(Socket,0) ConnectSocket(Socket,DotToIntIP("69.28.151.162:"),27011) WriteByte(Stream,$31) WriteByte(Stream,$00) WriteByte(Stream,Asc("0")) WriteByte(Stream,Asc(".")) WriteByte(Stream,Asc("0")) WriteByte(Stream,Asc(".")) WriteByte(Stream,Asc("0")) WriteByte(Stream,Asc(".")) WriteByte(Stream,Asc("0")) WriteByte(Stream,Asc(":")) WriteByte(Stream,$00) WriteByte(Stream,Asc("")) WriteByte(Stream,Asc("g")) WriteByte(Stream,Asc("a")) WriteByte(Stream,Asc("m")) WriteByte(Stream,Asc("e")) WriteByte(Stream,Asc("d")) WriteByte(Stream,Asc("i")) WriteByte(Stream,Asc("r")) WriteByte(Stream,Asc("")) WriteByte(Stream,Asc("c")) WriteByte(Stream,Asc("s")) WriteByte(Stream,Asc("t")) WriteByte(Stream,Asc("r")) WriteByte(Stream,Asc("i")) WriteByte(Stream,Asc("k")) WriteByte(Stream,Asc("e")) WriteByte(Stream,$00) Repeat ReadByte(Stream) Until SocketReadAvail(Socket)<=0 CloseSocket(Socket) End Function DotToIntIP:Int(IP:String) Local off1:Int=Instr(ip$,".") Local ip1:String=Left$(ip$,off1-1) Local off2:Int=Instr(ip$,".",off1+1) Local ip2:String=Mid$(ip$,off1+1,off2-off1-1) Local off3:Int=Instr(ip$,".",off2+1) Local ip3:String=Mid$(ip$,off2+1,off3-off2-1) Local off4:Int=Instr(ip$," ",off3+1) Local ip4:String=Mid$(ip$,off3+1,off4-off3-1) Return Int(ip1) Shl 24 + Int(ip2) Shl 16 + Int(ip3) Shl 8 + Int(ip4) End Function
Now, I know the server replies, SocketReadAvail returns I think 1428 for me but when I try to read, with ReadByte I get "Error reading from stream."
Can anyone help me?