The code below is how it receives messages via a loop
private: void RunIMServer() {
while (!stopped) {
TcpClient^ client = imListener->AcceptTcpClient();
String^ data;
// See if the client is connected
while (client->Connected) {
//if (client->Connected) {
NetworkStream^ stream = client->GetStream();
// Create our byte array for reading
array<unsigned char,1>^ bytes = gcnew array<unsigned char>(256);
// Loop to receive all the data sent by the client.
while (int i = stream->Read(bytes, 0, bytes->Length)) {
// Translate data bytes to a ASCII String*
data = System::Text::Encoding::ASCII->GetString(bytes, 0, i);
insertText(data);
}
// Close our connect
//client->Close();
}
// Close our connect
client->Close();
} // End While
} // End RunIMServer


Sign In
Create Account


Back to top









