|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
Imports System.Net.Sockets
Module Module1
Sub Main()
Try
Dim port As Int32 = 2710
Dim client As New TcpClient("localhost", port)
'mit 0x00 Verbindung aufbauen 0x00 = &H0
Dim message As Byte() = New Byte() {&H0}
' t-Token als Byte array.
Dim data As [Byte]() = System.Text.Encoding.ASCII.GetBytes("t\0V9.0afi \0http://localhost/\00\01.6.0_26 - 3911\0Java HotSpot(TM) Client VM\0-kzbvc87ti7he-1482lk01tash8,null")
Dim stream As NetworkStream = client.GetStream()
client.GetStream.Flush()
' Daten an Server senden
stream.Write(message, 0, message.Length)
stream.Write(data, 0, data.Length)
Console.WriteLine("Sent: {0}", System.Text.Encoding.ASCII.GetString(data))
' Daten empfangen
data = New [Byte](256) {}
Dim responseData As [String] = [String].Empty
Dim bytes As Int32 = stream.Read(data, 0, data.Length)
responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes)
Console.WriteLine("Received: {0}", responseData)
Catch e As ArgumentNullException
Console.WriteLine("ArgumentNullException: {0}", e)
Catch e As SocketException
Console.WriteLine("SocketException: {0}", e)
End Try
End Sub
End Module
|
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
Imports System.Net.Sockets
Module Module1
Sub Main()
Try
Dim port As Int32 = 2710
Dim client As New TcpClient("localhost", port)
'mit 0x00 Verbindung aufbauen 0x00 = &H0
Dim message As Byte() = New Byte() {&H0}
' t-Token als Byte array.
Dim data As [Byte]() = System.Text.Encoding.UTF8.GetBytes("0t" + vbNullChar + "V9.0afi ")
Dim stream As NetworkStream = client.GetStream()
client.GetStream.Flush()
' Daten an Server senden
stream.Write(message, 0, message.Length)
stream.Write(data, 0, data.Length)
Console.WriteLine("Sent: {0}", System.Text.Encoding.ASCII.GetString(data))
' Receive the TcpServer.response.
' Buffer to store the response bytes.
data = New [Byte](256) {}
' String to store the response ASCII representation.
Dim responseData As [String] = [String].Empty
' Read the first batch of the TcpServer response bytes.
Dim bytes As Int32 = stream.Read(data, 0, data.Length)
responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes)
Console.WriteLine("Received: {0}", responseData)
' Close everything.
Dim n As [Byte]() = System.Text.Encoding.UTF8.GetBytes("0n" + vbNullChar + "channel" + vbNullChar + "nick" + vbNullChar + "pw")
stream.Write(n, 0, n.Length)
Dim Hi As [Byte]() = System.Text.Encoding.UTF8.GetBytes("0e" + vbNullChar + "channel" + vbNullChar + "Hallo :)" + vbNullChar)
stream.Write(Hi, 0, Hi.Length)
Dim a As [Byte]() = System.Text.Encoding.UTF8.GetBytes("0d" + vbNullChar)
stream.Write(a, 0, a.Length)
Catch e As ArgumentNullException
Console.WriteLine("ArgumentNullException: {0}", e)
Catch e As SocketException
Console.WriteLine("SocketException: {0}", e)
End Try
Console.WriteLine(ControlChars.Cr + " Press Enter to continue...")
Console.Read()
End Sub 'Connect
End Module
|
Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »uncopyable« (7. September 2011, 21:10)

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Brainy« (8. September 2011, 04:06)