Click here to Skip to main content
16,005,222 members
Home / Discussions / C#
   

C#

 
GeneralRe: Threading issue Pin
theonewithtom20-Aug-06 5:46
theonewithtom20-Aug-06 5:46 
GeneralRe: Threading issue [modified] Pin
Nader Elshehabi20-Aug-06 10:12
Nader Elshehabi20-Aug-06 10:12 
GeneralRe: Threading issue Pin
theonewithtom20-Aug-06 23:55
theonewithtom20-Aug-06 23:55 
GeneralRe: Threading issue Pin
Nader Elshehabi21-Aug-06 1:42
Nader Elshehabi21-Aug-06 1:42 
QuestionRe: Threading issue Pin
theonewithtom21-Aug-06 4:27
theonewithtom21-Aug-06 4:27 
AnswerRe: Threading issue Pin
Nader Elshehabi21-Aug-06 5:15
Nader Elshehabi21-Aug-06 5:15 
AnswerRe: Threading issue Pin
S. Senthil Kumar20-Aug-06 19:08
S. Senthil Kumar20-Aug-06 19:08 
AnswerRe: Threading issue Pin
Andrei Ungureanu20-Aug-06 20:28
Andrei Ungureanu20-Aug-06 20:28 
Hi,
Try this code. Maybe will help.
<br />
Socket m_tcpListener = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);<br />
m_tcpListener.Bind(new IPEndPoint(IPAddress.Any,20000));<br />
Socket client = m_tcpListener.Accept();<br />
Thread clientThread = new Thread(new ThreadStart( (new ServeClient(client)).Start  ));<br />
clientThread.Start();<br />
<br />
class ServeClient<br />
{<br />
  private Socket client = null;<br />
<br />
  public ServeClient(Socket client)<br />
  {<br />
    this.client = client;<br />
  }<br />
 <br />
  public void Start()<br />
  {<br />
    //Do your work here<br />
  }<br />
}<br />

I created the class named ServeClient in which you cand do all your work. In my example for each client a new thread is launched. If you want to limit the number of clients that connect at the same time to your server (and the number of threads) you can call the Listen method of the socket.
Hope it helps

Do your best to be the best

QuestionInstall !!? Pin
MHASSANF20-Aug-06 2:48
MHASSANF20-Aug-06 2:48 
QuestionRe: Install !!? Pin
Anthony Mushrow20-Aug-06 3:05
professionalAnthony Mushrow20-Aug-06 3:05 
QuestionRe: Install !!? [modified] Pin
MHASSANF20-Aug-06 3:10
MHASSANF20-Aug-06 3:10 
AnswerRe: Install !!? Pin
Vitaliy Tsvayer20-Aug-06 3:32
Vitaliy Tsvayer20-Aug-06 3:32 
GeneralRe: Install !!? Pin
thunderbirdje20-Aug-06 10:54
thunderbirdje20-Aug-06 10:54 
AnswerRe: Install !!? Pin
Nader Elshehabi20-Aug-06 4:50
Nader Elshehabi20-Aug-06 4:50 
GeneralRe: Install !!? Pin
Anthony Mushrow20-Aug-06 10:59
professionalAnthony Mushrow20-Aug-06 10:59 
QuestionHaving a strange problem... Pin
Anthony Mushrow20-Aug-06 2:42
professionalAnthony Mushrow20-Aug-06 2:42 
AnswerRe: Having a strange problem... Pin
leppie20-Aug-06 3:12
leppie20-Aug-06 3:12 
GeneralRe: Having a strange problem... Pin
Anthony Mushrow20-Aug-06 11:02
professionalAnthony Mushrow20-Aug-06 11:02 
GeneralRe: Having a strange problem... [modified] Pin
Anthony Mushrow20-Aug-06 11:08
professionalAnthony Mushrow20-Aug-06 11:08 
GeneralRe: Having a strange problem... Pin
leppie20-Aug-06 11:25
leppie20-Aug-06 11:25 
GeneralRe: Having a strange problem... Pin
Anthony Mushrow20-Aug-06 12:56
professionalAnthony Mushrow20-Aug-06 12:56 
GeneralRe: Having a strange problem... Pin
Anthony Mushrow20-Aug-06 12:59
professionalAnthony Mushrow20-Aug-06 12:59 
GeneralRe: Having a strange problem... [modified] Pin
beatles169220-Aug-06 20:09
beatles169220-Aug-06 20:09 
GeneralRe: Having a strange problem... Pin
Anthony Mushrow21-Aug-06 3:58
professionalAnthony Mushrow21-Aug-06 3:58 
GeneralRe: Having a strange problem... Pin
Anthony Mushrow21-Aug-06 5:54
professionalAnthony Mushrow21-Aug-06 5:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.