Reputation: 173
I am using:
http://msdn.microsoft.com/en-us/library/system.net.sockets.tcpclient.aspx#Y2160
to connect and get information from a server. This is my code:
// Connect to the server
TcpClient^ client = gcnew TcpClient( "1.1.1.1", 45257 );
// Get stream
NetworkStream^ stream = client->GetStream();
// Data to send
array<Byte>^data = Text::Encoding::ASCII->GetBytes( message );
// Send data to server
stream->Write( data, 0, data->Length );
However, I am getting these errors:
error C3083: 'Encoding': the symbol to the left of a '::' must be a type
error C2039: 'ASCII' : is not a member of 'System::Windows::Forms::Form::Text'
error C2065: 'ASCII' : undeclared identifier
error C2227: left of '->GetBytes' must point to class/struct/union/generic type
This is inside of a windows form application.
Any help would be appreciated. Thanks
Upvotes: 2
Views: 4351
Reputation: 27864
Either specify the name space in a using directive, using namespace System::Text;
, or specify the class name with full namespace, System::Text::Encoding
.
Upvotes: 3