Click here to Skip to main content
15,910,877 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
QuestionWhat is wrong with this ? ? ? Pin
Zealous_Me4-Mar-07 9:43
Zealous_Me4-Mar-07 9:43 
AnswerRe: What is wrong with this ? ? ? Pin
Newbie004-Mar-07 10:06
Newbie004-Mar-07 10:06 
AnswerRe: What is wrong with this ? ? ? [modified] Pin
prasad_som4-Mar-07 16:56
prasad_som4-Mar-07 16:56 
AnswerRe: What is wrong with this ? ? ? Pin
toxcct5-Mar-07 5:18
toxcct5-Mar-07 5:18 
QuestionStrings......Okay this is probably well known, but.... Pin
Giles4-Mar-07 4:37
Giles4-Mar-07 4:37 
AnswerRe: Strings......Okay this is probably well known, but.... Pin
Newbie004-Mar-07 5:08
Newbie004-Mar-07 5:08 
GeneralRe: Strings......Okay this is probably well known, but.... Pin
Giles4-Mar-07 5:13
Giles4-Mar-07 5:13 
QuestionI need help about multithreading in TCPListener ... Pin
Nonreturn1-Mar-07 16:49
Nonreturn1-Mar-07 16:49 
In a TCPListener program I've coded, I used the sample codes about TCPListener I found in MSDN Library. But, when I execute this program, the interface doesn't give any response to other events such as clicking buttons, since the continuous loop prevents the other codes to be run. I know that I must do multithreading, but I don't know how to do. . Meanwhile, I also tried to use "BackgroundWorker" component, but it caused the data transfer to fail. Here's sample code, what can I do?


private:
void ServerActivate()
{
try
{
Int32 port = 10000;
IPAddress^ localAddr = IPAddress::Parse(myipBox->Text);
TcpListener^ server = gcnew TcpListener(localAddr,port);
server->Start();
array<byte>^bytes = gcnew array<byte>(256);
String^ data = nullptr;

// Enter the listening loop.
while (true)
{
MessageBox::Show("Ready To Receive!");
TcpClient^ client = server->AcceptTcpClient();
NetworkStream^ stream = client->GetStream();
Int32 i;

while ( i = stream->Read( bytes, 0, bytes->Length ) )
{
data = System::Text::Encoding::ASCII->GetString( bytes, 0, i );
outputBox->Items->Add(data);
data = data->ToUpper();
array<byte>^msg = System::Text::Encoding::ASCII->GetBytes(data);
stream->Write( msg, 0, msg->Length );
}
client->Close();
}
}
catch (SocketException^ e)
{
MessageBox::Show("Socket Exception Occured!");
ShowLoginBox();
}
}
AnswerRe: I need help about multithreading in TCPListener ... Pin
led mike2-Mar-07 6:01
led mike2-Mar-07 6:01 
GeneralRe: I need help about multithreading in TCPListener ... Pin
Nonreturn5-Mar-07 14:09
Nonreturn5-Mar-07 14:09 
GeneralRe: I need help about multithreading in TCPListener ... Pin
led mike6-Mar-07 4:28
led mike6-Mar-07 4:28 
Questionsomethings wrong Pin
Kiethnt1-Mar-07 16:34
Kiethnt1-Mar-07 16:34 
GeneralRe: somethings wrong Pin
prasad_som1-Mar-07 17:14
prasad_som1-Mar-07 17:14 
Questioncomplete Pin
Kiethnt1-Mar-07 16:22
Kiethnt1-Mar-07 16:22 
GeneralRe: complete Pin
prasad_som1-Mar-07 17:11
prasad_som1-Mar-07 17:11 
QuestionHelp Pin
Spartan161-Mar-07 9:54
Spartan161-Mar-07 9:54 
AnswerRe: Help Pin
Newbie001-Mar-07 11:11
Newbie001-Mar-07 11:11 
AnswerRe: Help Pin
Mark Salsbery1-Mar-07 11:32
Mark Salsbery1-Mar-07 11:32 
AnswerRe: Help Pin
led mike1-Mar-07 11:41
led mike1-Mar-07 11:41 
AnswerRe: Help Pin
Christian Graus1-Mar-07 13:03
protectorChristian Graus1-Mar-07 13:03 
GeneralRe: Help Pin
Spartan162-Mar-07 6:32
Spartan162-Mar-07 6:32 
QuestionRead from file into array Pin
JBAK_CP1-Mar-07 2:33
JBAK_CP1-Mar-07 2:33 
AnswerRe: Read from file into array Pin
prasad_som1-Mar-07 2:38
prasad_som1-Mar-07 2:38 
AnswerRe: Read from file into array Pin
Hamid_RT1-Mar-07 6:49
Hamid_RT1-Mar-07 6:49 
QuestionVisual C++ 2005 Pin
MoustafaS28-Feb-07 21:00
MoustafaS28-Feb-07 21:00 

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.