TCP Coding with external app

Blitz3D Forums/Blitz3D Programming/TCP Coding with external app

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hi.. I came back

Every thing I tried failed, so I moved to VBasic Net to do some tests (haven't used it before) and I used this code:

Imports System.Net
Imports System.Net.Sockets
Imports System.Text

Class TCPSrv
    Shared Sub Main()
        Const portNumber As Integer = 18000
        Dim MyServer As IPAddress = CType(Dns.GetHostEntry("127.0.0.1").AddressList(0), IPAddress)

        Dim myTCPListener As New TcpListener(MyServer, portNumber)
        myTCPListener.Start()
        Console.WriteLine("Waiting for connection...")
        Try
            'Accept the pending client connection and return a TcpClient initialized for communication. 
            Dim tcpClient As TcpClient = myTCPListener.AcceptTcpClient()
            Console.WriteLine("Connection accepted.")
            ' Get the stream
            Dim networkStream As NetworkStream = tcpClient.GetStream()
            ' Read the stream into a byte array
            Dim bytes(tcpClient.ReceiveBufferSize) As Byte
            networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
            ' Return the data received from the client to the console.
            Dim clientdata As String = Encoding.ASCII.GetString(bytes)
            Console.WriteLine(("Client sent: " + clientdata))
            Dim responseString As String = "Connected to server."
            Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(responseString)
            networkStream.Write(sendBytes, 0, sendBytes.Length)
            Console.WriteLine(("Message Sent /> : " + responseString))
            'Any communication with the remote client using the TcpClient can go here.
            'Close TcpListener and TcpClient.
            tcpClient.Close()
            myTCPListener.Stop()
            Console.WriteLine("exit")
            Console.ReadLine()
        Catch e As Exception
            Console.WriteLine(e.ToString())
            Console.ReadLine()
        End Try
    End Sub
End Class


And it works!! The client application receives the data I'm sending back... So... Is it a Blitz3D bug?? :(