Hello, im making a gaming tool for my Call of Duty 4 server. Not sure if anyone here plays it, but it uses an ingame rcon command tool that you use for admin control on your server. Well i wanted to make a program that i can control my server without having to log ingame to do admin stuff. I seem to be having problems tho. Im trying to have my program retrieve current information on the server but can't seem to retrieve the information. I have been reading serveral UDP tutorials trying to learn udp and tcp. Im definately still new to all this and trying my hardest to learn. Here is my code. I commented parts to explain what its for incase noone knows what it is for the game.
CODE
Imports System
Imports System.Net
Imports System.Net.Sockets
Imports System.Text
Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form
' rconPassword is the password to login for admin control
Dim sPass As String = "/rcon login rconPassword"
' sv_hostname is the variable on the server that has text im trying to receive
Dim hostName As String = "sv_hostname"
' multi-line textbox named txtBox1 for sending the information to, to read
Private Sub txt(ByVal Text As String)
txtBox1.AppendText(Text & vbCrLf)
txtBox1.ScrollToCaret()
End Sub
Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
Dim udpClient As New UdpClient(12345)
Try
' Not the real ip address or port number
udpClient.Connect("123.45.67.89", 12345)
' Here i try to send the login attempt and hostname request
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(sPass & hostName)
udpClient.Send(sendBytes, sendBytes.Length)
Dim RemoteIpEndPoint As New IPEndPoint(IPAddress.Any, 0)
Dim receiveBytes As [Byte]() = udpClient.Receive(RemoteIpEndPoint)
Dim returnData As String = Encoding.ASCII.GetString(receiveBytes)
txt("Hostname: " + returnData.ToString())
udpClient.Close()
Catch ex As Exception
txt(ex.ToString())
End Try
End Sub
End Class
And the response i get from this is
CODE
Hostname: disconnect
Any help on this would be greatly appreciated. Thanks