Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


NetworkStream not including the last quotation?

Posted on 2009-07-09
Medium Priority
Last Modified: 2012-05-07
I'm trying to make a simple chat client.  But it seems that the "Dim ClientData As String = Encoding.ASCII.GetString(RevievedBytes)" is returning a string without the trailing quotation.  During a step-into, ClientData was "something.  If I manually put the other quotation on the end during a step-into, it would work.  Why is this happening?  Full project available at
Private Sub Listen(ByVal Server As String, ByVal PortNum As Int16)
    Dim MyTCPListener As New TcpListener(System.Net.IPAddress.Parse(Server), PortNum)
      Dim MyTCPClient As TcpClient = MyTCPListener.AcceptTcpClient()
      Dim NetworkStream As NetworkStream = MyTCPClient.GetStream()
      Dim RevievedBytes(MyTCPClient.ReceiveBufferSize) As Byte
      NetworkStream.Read(RevievedBytes, 0, CInt(MyTCPClient.ReceiveBufferSize))
      Dim ClientData As String = Encoding.ASCII.GetString(RevievedBytes)
      'Dim data2 As String = ClientData & Chr(34)
      Dim ClientParameters() As String = ClientData.Split("~")
      Dim ResponseString As String = ""
      Status = ClientData
      Select Case ClientParameters(0)
        Case "/send"
          ResponseString = "/print~" & ClientParameters(1)
        Case "/connect"
          ResponseString = "/ok"
      End Select
      Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(ResponseString)
      NetworkStream.Write(sendBytes, 0, sendBytes.Length)
    Catch ex As Exception
    End Try
  End Sub

Open in new window

Question by:freebullets
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 41

Expert Comment

ID: 24841075
add a line after your Write() method

Author Comment

ID: 24846497
The problem is visible at this line.  When stepping into, the value of it is "clientdatahere.  It should be "clientdatahere".
Dim ClientData As String = Encoding.ASCII.GetString(RevievedBytes)

Open in new window


Accepted Solution

freebullets earned 0 total points
ID: 25002067
I fixed it by using StreamReader/Writer instead.

Featured Post

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question