Reputation: 447
I am writing a Winsock application and at one point I need to form the tcp message which is an http get request for a webpage.
char clientmessage[] = "GET / HTTP/1.1\r\n\r\n";
Console::WriteLine(clientmessage);
When I try to print out the message useing Console::WriteLine()
method it prints True
. I've considered it may be an issue with the method and maybe I nee to use puts()
as is done in this tutorial.
http://www.binarytides.com/winsock-socket-programming-tutorial/
Any help is appreciated.
Upvotes: 1
Views: 340
Reputation: 5135
It seems like it implicitly converts an unmanaged pointer to System.Boolean
.
In order to use .NET APIs, you need to marshal the parameters. In this case you need to marshal clientmessage
into System::String^
. You can do this with the System::Runtime::InteropServices::Marshal::PtrToStringAnsi()
method.
char clientmessage[] = "GET / HTTP/1.1\r\n\r\n";
System::String^ str = System::Runtime::InteropServices::Marshal::PtrToStringAnsi(static_cast<System::IntPtr>(clientmessage));
Console::WriteLine(str);
Upvotes: 3