Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

vb.net - tcpclient.networkstream help

  • 09-12-2008 10:58pm
    #1
    Registered Users, Registered Users 2 Posts: 938 ✭✭✭


    I'm trying to read data, send data, read data again from telnet session. The first reading comes in ok but the second doesn't. I can't seem to see what I'm doing wrong. I'm just learning this stuff btw,
    
            Dim tcpClient As New System.Net.Sockets.TcpClient()
            tcpClient.Connect(txtip.Text, txtport.Text)
            Dim networkStream As System.Net.Sockets.NetworkStream = tcpClient.GetStream()
            If networkStream.CanWrite And networkStream.CanRead Then
    
                Dim bytes(tcpClient.ReceiveBufferSize) As Byte
                Dim sendBytes As [Byte]()
                Dim returndata As String = ""
    
                '***read the data from the server in to the string returndata
                networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
                returndata = System.Text.Encoding.ASCII.GetString(bytes)
    
    
                networkStream.Flush() '***clear off the current data
    
                '***send data "admin" to the server
                sendBytes = System.Text.Encoding.ASCII.GetBytes("admin")
                networkStream.Write(sendBytes, 0, sendBytes.Length)
    
                networkStream.Flush() '***clear off the current data
    
                '***read the data from the server in to the string returndata
                networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
                returndata = System.Text.Encoding.ASCII.GetString(bytes)
    


Advertisement