race 07 dedicated server ports

Dedicated server ports

Quote Originally Posted by Achim Ennenbach View Post

I want to query the game for current trackname, session and what's possible else. I think that's what you call "outbound", right?
I don't want to control rfactor, simply "ask for information".

I am not sure what languages you know, but here is some VB.Net sample code for querying a server. If you have any questions about this code just ask:

Code:

Sub query() tbStatus.Text = "" Dim udpClient As New System.Net.Sockets.UdpClient udpClient.Connect(tbIP.Text, tbPort.Text) udpClient.Send(System.Text.Encoding.ASCII.GetBytes("rF_S\0"), 6) Dim RemoteIpEndPoint As New System.Net.IPEndPoint(System.Net.IPAddress.Any, 0) Dim receiveBytes As Byte() = udpClient.Receive(RemoteIpEndPoint) tbStatus.AppendText("Gameversion: " & ShortFromBuffer(receiveBytes, &H11).ToString()) tbStatus.AppendText(vbCrLf & "Server Name: " & StringFromBuffer(receiveBytes, &H2D).ToString()) tbStatus.AppendText(vbCrLf & "MOTD: " & StringFromBuffer(receiveBytes, &H69).ToString()) tbStatus.AppendText(vbCrLf & "Series: " & StringFromBuffer(receiveBytes, &H19).ToString()) tbStatus.AppendText(vbCrLf & "Track: " & StringFromBuffer(receiveBytes, &H49).ToString()) tbStatus.AppendText(vbCrLf & "Session: " & (ByteFromBuffer(receiveBytes, &HD2) >> 5).ToString()) tbStatus.AppendText(vbCrLf & "Session Time: " & ShortFromBuffer(receiveBytes, &HD9).ToString()) tbStatus.AppendText(vbCrLf & "Session Laps: " & (ShortFromBuffer(receiveBytes, &HDB) / 16).ToString()) tbStatus.AppendText(vbCrLf & "Current Players: " & ByteFromBuffer(receiveBytes, &HCF).ToString()) tbStatus.AppendText(vbCrLf & "Max Players: " & ByteFromBuffer(receiveBytes, &HD0).ToString()) End Sub Private Function StringFromBuffer(ByVal buffer As Byte(), ByVal idx As Byte) As String Dim returnString As String = "" While buffer(idx) <> &H0 returnString = returnString & Char.ConvertFromUtf32(buffer(idx)) idx = idx + 1 End While Return returnString End Function Private Function ByteFromBuffer(ByVal buffer As Byte(), ByVal idx As Byte) As Integer Return buffer(idx) End Function Private Function ShortFromBuffer(ByVal buffer As Byte(), ByVal idx As Byte) As Integer Return buffer(idx) Or (buffer(idx + 1) << 8) End Function Private Function LongFromBuffer(ByVal buffer As Byte(), ByVal idx As Byte) As Integer Return buffer(idx) Or (buffer(idx + 1) << 8) Or (buffer(idx + 2) << 16) Or (buffer(idx + 3) << 24) End Function

FOLLOW US ON

Copyrights © 2017