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

Problem in MultiThreading

108 100+
Hi guys,
I just want to ask what is the best way in my current problem. I have a client/server application. Everytime a client connect to the server, I create a thread to handle it. I save the thread id in an array. My problem is that, when a client disconnect, I dont know which thread to destroy. If I can get the hostname or ip address, I can also save it together with the thread id and my problem is solved. But when a client connect to the server, I don't have that information. Can anyone help me?
Apr 15 '08 #1
3 925
Mr Gray
47
Hi guys,
I just want to ask what is the best way in my current problem. I have a client/server application. Everytime a client connect to the server, I create a thread to handle it. I save the thread id in an array. My problem is that, when a client disconnect, I dont know which thread to destroy. If I can get the hostname or ip address, I can also save it together with the thread id and my problem is solved. But when a client connect to the server, I don't have that information. Can anyone help me?
Can you create a manager to handle a list of the users and the threads that have been created? for example:

for every user that logs in you should associate the ip address and thread id that the user is on. everytime a user logs out a method would run that would check that list of users and then release/disconnect from the server as you desire.

This should get the users IP Address:
Expand|Select|Wrap|Line Numbers
  1. HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
  2.  
Look here: http://forums.asp.net/t/892765.aspx
Apr 15 '08 #2
romcab
108 100+
Can you create a manager to handle a list of the users and the threads that have been created? for example:

for every user that logs in you should associate the ip address and thread id that the user is on. everytime a user logs out a method would run that would check that list of users and then release/disconnect from the server as you desire.

This should get the users IP Address:
Expand|Select|Wrap|Line Numbers
  1. HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
  2.  
Look here: http://forums.asp.net/t/892765.aspx

Hi,
Tnx. That's what i'm trying to do right now. I will save the thread id and ip address of the client. My problem is how to get the ip address of the client. I'm only using Tcpclient and TcpListener class for my winforms application. I have no idea how to get the client information.
Apr 15 '08 #3
vanc
211 Expert 100+
Is it better if you can add delegate to those threads, so when it stopped, it'll call back and do whatever you want it to do. By doing this, you don't have to know which thread is stopped, since it knows itself. Cheers.
Apr 16 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: sarge | last post by:
I would like to know how to perform simple multithreading. I had created a simple form to test out if I was multithreading properly, but got buggy results. Sometime the whole thig would lock up...
2
by: Rich | last post by:
Hello, I have set up a multithreading routine in a Test VB.net proj, and it appears to be working OK in debug mode and I am not using synchronization. Multithreading is a new thing for me, and...
2
by: Multithreading problem in vb.net | last post by:
Greetings, I am new to multithreading and I am trying to implement it in my app. This application is distributed application which needs to refresh every say 5 secs to show some activities in...
4
by: Michael | last post by:
Hi, I am trying to create a multithreaded VB 2005 application which attempts to create a new thread per Domain Controller (DC) in my environment. Each thread connects to its allocated DC and...
7
by: Ray | last post by:
Hello, Greetings! I'm looking for a solid C++ multithreading book. Can you recommend one? I don't think I've seen a multithreading C++ book that everybody thinks is good (like Effective C++ or...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.