Newcomer's CAsyncSocket example: trouble connecting with other
clients
Hiya,
I'm using the AsyncServer portion from Dr. Newcomer's code found here:
http://www.flounder.com/kb192570.htm
I'm writing various clients using mfc and .net to see if I can send
messages to it.
Since I'm completely new to socket programming, let me start by
asking, "Can you only connect to his server app by using CAsyncSocket?
My current little bit of learning is to write a .net console app using
TcpClient to connect to it and send a message, but the message isn't
going through. The server shows a socket has been attached, but no
message gets sent, and then the socket disconnects with a message
?.?.?.? [?] Closed
OK, yes, I realize that this is an MFC group, but I'm also
unsuccessful writing an mfc console app that uses CSocket. Well,
anyway, here's the .net version:
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?