473,322 Members | 1,345 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,322 software developers and data experts.

Using Net.Sockets and encoding.ascii

Hi All,

I am trying to send information from my vb.Net
app to a piece of hardware with an embedded
TCP/IP controller using sockets.

I can send information so the sockets are working
but the data is garbage!!!

It works if the ascii of the character I am sending
is less than 127, however, if I send ascii 128 or
above (up to 255, obviously) then things start to
go wrong.

I am sure it is to do with the encoding of the
byte and thee fact that it seems to be signed
as oppossed to unsigned.

Decimal 1 in binary is
00000001

Decimal 127 in binary is
011111111

In an unisgned int, decimal 128 is
100000000

and decimal 255 is
11111111

How can I get this to be outputted to my
embedded controller using sockets???

Please help.

This is what I have used for my output stream to the
socket.

Dim writer As New IO.StreamWriter(m_Client.GetStream(),
System.Text.Encoding.ASCII)

Regards,

Jason.
Nov 21 '05 #1
3 1964
Hi,

Encoding.Ascii supports only ASCII (characters with values between 0 and
127, as you have observed). You should use a binary Writer, not Text.

Dim writer As New BinaryWriter(Stream)

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004.
Nov 21 '05 #2
Hi,

Encoding.Ascii supports only ASCII (characters with values between 0 and
127, as you have observed). You should use a binary Writer, not Text.

Dim writer As New BinaryWriter(Stream)

Dick

--
Richard Grier (Microsoft Visual Basic MVP)

See www.hardandsoftware.net for contact information.

Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004.
Nov 21 '05 #3
Thanks DIck,

that works great.

Jason.
On Thu, 23 Sep 2004 10:27:25 -0600, "Dick Grier"
<di**************@msn.com> wrote:
Hi,

Encoding.Ascii supports only ASCII (characters with values between 0 and
127, as you have observed). You should use a binary Writer, not Text.

Dim writer As New BinaryWriter(Stream)

Dick


Nov 21 '05 #4

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

Similar topics

1
by: Dmitry Akselrod | last post by:
Hello everyone, I have a vb.net application that wraps the TCPListener object in a class. The server connects to the local interface and establishes itself on port 9900. It then polls for...
1
by: Dave | last post by:
I'm have an app the opens a socket and I want the socket to stay open till the user clicks a button. I pass a string of "m_start" to start a listener, and "m_end" to the function listen_func to...
7
by: Rex Winn | last post by:
I've Googled until my eyes hurt looking for a way to issue Telnet commands from C# and cannot find anything but $300 libraries that encapsulate it for you. I don't want to be able to create a...
1
by: Brian Henry | last post by:
Hello, I was tring to learn socket's (being i never used them before) and have a simple question. I want to create a listner that will get any data recieved and print it out. I've been able to...
0
by: Tim Wagaman | last post by:
I an having issuses with a loop I am running to keep checking for messages coming across our line. The goal: Listen for messages on port 5001 and print the messages into a text file. The port...
0
by: Jason L James | last post by:
Hi All, I am trying to send information from my vb.Net app to a piece of hardware with an embedded TCP/IP controller using sockets. I can send information so the sockets are working but the...
1
by: Prasanta | last post by:
Hello, Please cnay one can tell me how to read mail as formatted.... i have made some code using that able to read but not able to serialize..... so am i need to parse the HTML, or is there any...
1
by: Prasanta | last post by:
Hello, How to read a mail from the mail server as formatted. I am able to read the mail as row HTML, is there any class, or something method using that i can easily get the all info of that...
3
by: shahla.saeed | last post by:
hi, plzz check my code and let me know where the problem is lying...becuase whenever i try to tansfer the file of 573KB(mp3) it just tranfer few Kb of file(Somtimes 5.2Kb,somtimes 32Kb..every time...
1
by: =?Utf-8?B?RGFydGgtQ3ot?= | last post by:
Hi, I'm beginner in Visual C++ so I want to ask you a question. And I'm not good in English:D So I have the program which communicates over sockets. The program has to connect to the server and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.