473,395 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

HELP:Weird string problem

I have written a TCP/IP server. The first thing a client does is send
login info in the form of FirstName LastName|mypassword@ I read this
in using the .GetByte method of a networkstream. I add the input as
entered into a byte array which upon receiving the "@" character I
convert into a string using the .GetChars method of an encoding
object. I then parse out the username and password into string
variables for use elsewhere. When I step through the code I find
something strange. In the Autos window at the bottom of the screen
the username will show as "FirstName LastName" (with the " characters)
but the password part shows as "mypassword with no closing "
character. Additionally, the unclosed string shows in red text and I
cannot use it in any other string. If I build a string and append the
password value anything that comes after the password will not show.
It is almost as though there is some special character at the end of
the string that will not allow anything to come after the last letter
entered before the "@"

Any help would be greatly appreciated.
Nov 19 '05 #1
2 1222
On Thu, 10 Jul 2003 00:35:03 GMT, ms****@mspeed.net wrote:

I figured this out. I was reading the input into a byte array of size
200. After the .GetChars method I needed to do a string =
left(string,numberofcharsreadin) to cut off the null space in the byte
array that didn't get filled by input.
Nov 19 '05 #2
>
The value you have read is Null terminated, and in VB (like most other
languages) a Null indicates the end of a string (even if there actually IS
more data after the null). Just curious, what encoding object are you using?

I ended up figuring it out. I am using encoding.UTF8.

If there is a better way to do this I'd love to hear it. I have never
written a TCP/IP server before and while I mostly understand what
sockets do I had never actually created one in a program. I am doing
what I was able to get to work, inefficient or not.

My code looks like this:

dim enc as encoding = encoding.UTF8

dim i as int16 = 0
dim cmdin(200) as byte
dim cmdstr as string
dim strm as networkstream = new networkstream(mysocket)
while true
try
cmdin(i) = strm.readbyte
'Check for @ end-of-command indicator
if cmdin(i) = "64" then
exit while
end if
i+=1
if i > 200 then
exit while
end if
catch
mysocket.close()
end try
end while

cmdstr = enc.getchars(cmdin)
cmdstr = left(cmdstr,i)

now I have a string I can work with



Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Stangonline.com | last post by:
Ok, im familiar with typical troubleshooting of this type on problem, but I do not do any programming myself. Im hoping you guys can help me with an install problem that I am having. I have an...
1
by: Travis Pupkin | last post by:
Hi, I'm passing a string (the file name of a photo) from a database, into a hidden form field, and then posted from that form into the HTML code of a multipart e-mail being sent by CDONTS. ...
2
by: oscar | last post by:
I have read Tony Toews's web site from which I have deduced I have an LDB locking problem. I have tried to follow his solution as follows: 1. I have created a dummy table in the back-end app....
5
by: יוני גולדברג | last post by:
Hi, While trying to create new directory i recieve the following error message: "System.IO.DirectoryNotFoundException: Could not find a part of the path "\\premfs16\sites". The path exists, even...
4
by: samadams_2006 | last post by:
Hello, I have a peculiar problem that I'm hoping someone can help me out with. I have a simple enough Web Application written in VB.Net via Visual Studio 2003. It simply displays a Web Form...
1
by: matt | last post by:
hello, i am accustomed to using the string.Format method in this way: string foo = string.Format("The formula is {0} * {1}", inputOne, inputTwo); but now i am trying to do one where i need...
2
by: Fred | last post by:
Hello, I am having a problem with a multiline string that I create from a byte array (xml file). I am using StringBuilder and Ecoding the string to ASCII (code below). / Upload the...
0
by: berry | last post by:
I met a strange scene in my code. I succeed to call out the number i want from the database. But when I sum it up, the amount is incorrect. Even i had pop up messagebox before it do the calculation....
7
by: cephal0n | last post by:
Hi there! I've been racking my brains out for 4 days and still not getting why is msaccess stubborn about string parsing, first I have a table named tblItems, this table has columns: ProductItem,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.