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
Connection control
Jan 10 2010 8:15 AM
Hi.
I am trying to make a client and a server. Server must be work always and sometimes I open and close the client program. When client is opened, I want to show a message on server side "client connected". Then if client program closed, there should be a message on server side "client unconnected.". I mean I want to control connected or unconnected always.
My codes are below; if client opened, "connected" message appeared. But when client closed, I couldnt see any message.
How can I control this?
public void Form1_Load(object sender, EventArgs e)
{
CheckForIllegalCrossThreadCalls = false;
thread_dinleyici = new Thread(new ThreadStart(dinle));
thread_dinleyici.Start();
}
public void dinle()
{
tcp_listener = new TcpListener(3333);
tcp_listener.Start();
while (true)
{
try
{
istemcisoketi = tcp_listener.AcceptSocket();
if (istemcisoketi.Connected)
{
label1.Text = "connected";
}
else
{
label1.Text = "unconnected";
}
}
catch
{
}
}
}
Reply
Answers (
4
)
Need help with IOException
use of Interface