Managed C++ Chat Server Problem
-
Well I want to write a chat server. I know i gotta use threads for this curelltly i do it like this: TcpListener *pTcpListener; pTcpListener = new TcpListener(80); int i=0; while (1) { pTcpListener->Start(); MyThread * Clients; TcpClient * pTcpClient; pTcpClient = pTcpListener->AcceptTcpClient(); Clients = new MyThread(true, "Client", pTcpClient); /*asicly start thread*/ } Well the problem is i can't send to client unless he sends a request because I can't acces the Objects individually :( what to do?
-
Well I want to write a chat server. I know i gotta use threads for this curelltly i do it like this: TcpListener *pTcpListener; pTcpListener = new TcpListener(80); int i=0; while (1) { pTcpListener->Start(); MyThread * Clients; TcpClient * pTcpClient; pTcpClient = pTcpListener->AcceptTcpClient(); Clients = new MyThread(true, "Client", pTcpClient); /*asicly start thread*/ } Well the problem is i can't send to client unless he sends a request because I can't acces the Objects individually :( what to do?
random looser wrote: Well the problem is i can't send to client unless he sends a request because I can't acces the Objects individually what to do? I might have misunderstood you, but is your problem that of passing values to your thread? If so read this article :- http://www.codeproject.com/useritems/mcppthreads01.asp Nish
Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.