PDA

View Full Version : Telnet and broadcasting


nosfentora
07-09-2008, 08:49 AM
I'm writing some code to broadcast to the server through a tool i'm working on.

Using the following code it works

Dim lReturn As Object
lReturn = IIf(My.Settings.ShowTelnet, Shell("Telnet " & My.Settings.BroadcastServerIP & " " & My.Settings.BroadcastServerPort, AppWinStyle.NormalFocus, False), Shell("Telnet " & My.Settings.BroadcastServerIP & " " & My.Settings.BroadcastServerPort, AppWinStyle.Hide, False))
Sleep(5)
AppActivate(lReturn)
Sleep(2)
''login
System.Windows.Forms.SendKeys.SendWait(My.Settings .BroadcastUsername & "{ENTER}")
Sleep(2)
'' pass
System.Windows.Forms.SendKeys.SendWait(My.Settings .BroadcastPassword & "{ENTER}")
Sleep(2)
''broadcast message
System.Windows.Forms.SendKeys.SendWait("broadcast " & msg & "{ENTER}")
Sleep(1)
''LOGOFF
System.Windows.Forms.SendKeys.SendWait("exit{ENTER}")
Sleep(2)
''CLOSE TELNET
System.Windows.Forms.SendKeys.SendWait("{ENTER}")
System.Windows.Forms.SendKeys.SendWait("%{F4}")
*BUT* it does not work if the computer is locked (the telnet window stays open and times out - preventing any future broadcasts)

So I tried this:


Dim sock As System.Net.Sockets.Socket
sock = New System.Net.Sockets.Socket(AddressFamily.InterNetwo rk, SocketType.Stream, ProtocolType.Tcp)
sock.Connect(My.Settings.BroadcastServerIP, Val(My.Settings.BroadcastServerPort))
If sock.Connected Then
sock.Send(System.Text.Encoding.ASCII.GetBytes(My.S ettings.BroadcastUsername & vbCrLf))
sock.Send(System.Text.Encoding.ASCII.GetBytes(My.S ettings.BroadcastPassword & vbCrLf))
sock.Send(System.Text.Encoding.ASCII.GetBytes("broadcast " & msg & vbCrLf))
sock.Send(System.Text.Encoding.ASCII.GetBytes("exit" & vbCrLf & vbCrLf))
sock.Shutdown(SocketShutdown.Both)
sock.Disconnect(False)
sock.Close()
Log.WriteLine("Message Broadcasted!")
Else
Log.WriteLine("Failed to connect!")
End If
sock = Nothing
This worked once, and then continues to output the following in the World.exe window:
[DEBUG] [WORLD__ZONE] New TCP Connection from 0.0.0.0:0
[DEBUG] [WORLD__CONSOLE] removing concole (!tcp -> connected) from 0.0.0.0:

I then tried this:

Dim ip As New System.Net.IPEndPoint(System.Net.Dns.GetHostAddres ses(My.Settings.BroadcastServerIP)(0), My.Settings.BroadcastServerPort)
Dim client As New System.Net.Sockets.TcpClient()
client.Connect(ip)
If client.Connected Then
Dim myWrite As System.IO.StreamWriter = New System.IO.StreamWriter(client.GetStream())
myWrite.WriteLine(My.Settings.BroadcastUsername)
myWrite.WriteLine(My.Settings.BroadcastPassword)
myWrite.WriteLine("broadcast " & msg)
myWrite.WriteLine("exit")
myWrite.Close()
client.Close()
End If
which never worked and constantly output
[DEBUG] [WORLD__ZONE] New TCP Connection from 0.0.0.0:0
[DEBUG] [WORLD__CONSOLE} removing concole (!tcp -> connected) from 0.0.0.0:

in the World.exe window

Any thoughts from the developers on a possible solution? The easiest would be to turn off the auto-lock on the computer, but I'd prefer not to.

(if this is the wrong area to post - please feel free to move it)

LordRathgil
07-09-2008, 12:05 PM
Ive got a gui that ive been working on for a bit that handles all that it does the same in world but it works fine its in c#.net though not vb.net

nosfentora
07-09-2008, 01:05 PM
i was watching in game to see if it broadcasted or not and it never did (when the ip 0.0.0.0:0 came up).

.net is pretty much the same all the way round - just minor syntax changes

if you wouldn't mind sharing the broadcasting portion of your code i'd appreciate it.

LordRathgil
07-09-2008, 02:17 PM
yeah ill just give you my whole gui provided you dont release the source ( dont want someone using it to cheat on servers taht aint their own and im sure someone will figure out how lol) Let me upload it and ill pm you the link

nosfentora
07-09-2008, 03:17 PM
Thanks - i greatly appreciate it! And I won't release the source.