TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ash SR
NA
1
1.2k
Getting junk values while converting network stream to strin
Apr 8 2014 2:37 AM
I have tried to read a text file through command prompt. Using the following steps 1. Enabled telnet server in the server pc and client in my pc. 2. change telnet port in server pc to 24 3. Using telnet command connect to server pc. 4. from telnet window> using type display the content of the text file in command prompt.
Now I want to do the same from my c# code. I have written the following code:
TcpClient tcpclient = new TcpClient();
tcpclient.Connect(<ip address>, <port>);
NetworkStream ns = tcpclient.GetStream();
StreamReader streamReader = new StreamReader(ns);
byte[] msg = Encoding.ASCII.GetBytes("type <file location>");
string returnd = Encoding.ASCII.GetString(msg);
ns.Write(msg, 0, msg.Length);
StreamWriter streamWriter = new St byte[] bytes = new byte[tcpclient.ReceiveBufferSize];
int bytesread = tcpclient.ReceiveBufferSize;
ns.Read(bytes, 0, bytesread);
reamWriter(ns);
string returndata = Encoding.ASCII.GetString(bytes);
but my code is always giving some junk output like " ÿý%ÿûÿûÿý'ÿýÿý"
Reply
Answers (
0
)
How to get network card description of local area connection
Any two features of VB.NET