Re: Newcomer's CAsyncSocket example: trouble connecting with other clients
- From: Hector Santos <sant9442@xxxxxxxxx>
- Date: Wed, 12 May 2010 01:17:55 -0400
stephen park wrote:
Console::WriteLine( "Sending message" );
>
TcpClient^ client = gcnew TcpClient( IP, PORT );
>
NetworkStream ^stream = client->GetStream();
String^ msg = "hello there";
array<Byte>^data = Text::Encoding::ASCII->GetBytes( msg );
try {
stream->Write( data, 0, data->Length );
stream->Flush();
}
catch( Exception ^e) {
Console::WriteLine( e->StackTrace );
}
client->Close();
Nothing really seems to jump out at me, but maybe someone else can see
something?
Well, you are writing then closing immediately, thus killing the transmission before it is even finished.
Try this:
Console::WriteLine(L"- Connecting");
TcpClient^ clnt = gcnew TcpClient( YOUR_IP, YOUR_PORT);
Console::WriteLine(L"- Connected. PAK to close");
Console::ReadKey();
clnt->Close();
Console::WriteLine(L"- Closed. PAK to exit");
Console::ReadKey();
Throw in some PAKs (Press Any Key) to give time to work. :)
--
HLS
.
- Follow-Ups:
- Re: Newcomer's CAsyncSocket example: trouble connecting with other clients
- From: Hector Santos
- Re: Newcomer's CAsyncSocket example: trouble connecting with other clients
- References:
- Newcomer's CAsyncSocket example: trouble connecting with other clients
- From: stephen park
- Newcomer's CAsyncSocket example: trouble connecting with other clients
- Prev by Date: Re: General Question ... Class & Members
- Next by Date: cannot execute C preprocessor cl.exe
- Previous by thread: Re: Newcomer's CAsyncSocket example: trouble connecting with other clients
- Next by thread: Re: Newcomer's CAsyncSocket example: trouble connecting with other clients
- Index(es):
Relevant Pages
|