Lid |
|
Hiya ppl,
ik heb een probleempje met mijn script:
Imports System
Imports System.IO
Imports System.Net
Imports System.Net.Sockets.TcpClient
Imports System.Net.Sockets
Imports System.Text
Class TCPClient
Shared Sub Main()
Dim tcpClient As New System.Net.Sockets.TcpClient
tcpClient.Connect("127.0.0.1", 6667)
Dim networkStream As NetworkStream = tcpClient.GetStream
If networkStream.CanWrite And networkStream.CanRead Then
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("test")
networkStream.Write(sendBytes, 0, sendBytes.Length)
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
Dim returndata As String = Encoding.ASCII.GetString(bytes)
Console.WriteLine(("Data: " + returndata))
Else
If Not networkStream.CanRead Then
Console.WriteLine("cannot not write data to this stream")
tcpClient.Close()
Else
If Not networkStream.CanWrite Then
Console.WriteLine("cannot read data from this stream")
tcpClient.Close()
End If
End If
End If
Console.ReadLine()
End Sub
End Class
Imports System Imports System.IO Imports System.Net Imports System.Net.Sockets.TcpClient Imports System.Net.Sockets Imports System.Text Class TCPClient Shared Sub Main() Dim tcpClient As New System.Net.Sockets.TcpClient tcpClient.Connect("127.0.0.1", 6667) Dim networkStream As NetworkStream = tcpClient.GetStream If networkStream.CanWrite And networkStream.CanRead Then Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("test") networkStream.Write(sendBytes, 0, sendBytes.Length) Dim bytes(tcpClient.ReceiveBufferSize) As Byte networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize)) Dim returndata As String = Encoding.ASCII.GetString(bytes) Console.WriteLine(("Data: " + returndata)) Else If Not networkStream.CanRead Then Console.WriteLine("cannot not write data to this stream") tcpClient.Close() Else If Not networkStream.CanWrite Then Console.WriteLine("cannot read data from this stream") tcpClient.Close() End If End If End If Console.ReadLine() End Sub End Class
De code geeft geen error message.. maar mijn server krijgt niks binnen.
Wat doe ik fout?
|