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
yokzu
NA
306
0
Socket programming
Dec 27 2009 7:49 PM
Hi.
I am trying to some socket programs. Below, server side program's codes. Its getting the messages from client with no problem. I want to count this messages length and sending again to client. But it doesnt work. Where am I mistaken?
public NetworkStream str;
public StreamReader str_rdr;
public StreamWriter str_wrt;
public Socket clientsoket;
public void Form1_Load(object sender, EventArgs e)
{
CheckForIllegalCrossThreadCalls = false;
Thread thread_listener = new Thread(new ThreadStart(listen));
thread_listener.Start();
}
public void listen()
{
TcpListener listener = new TcpListener(30000);
while (true)
{
listener.Start();
Socket clientsocket = listener.AcceptSocket();
NetworkStream str = new NetworkStream(clientsoket);
StreamReader str_rdr = new StreamReader(str);
string var1 = str_rdr.ReadLine();
textBox1.Text = var1; // ----> In here, I am seeing client's message.
StreamWriter str_wrt = new StreamWriter(str);
str_wrt.WriteLine(textBox1.Text.Length);
str_wrt.Flush();
}
}
Reply
Answers (
5
)
Getting variable in another function
How to make key event of virtual keyboard while Inputed object isn't lost focus that same with On-Screen Keyboard