The problem with VB.NET or even C# code is that it requires th .NET framework and Common Language Runtime(CLR). Dev-C++ (or specifically GCC) supports neither.
Microsoft's C++ compiler supports C++/CLI a C++ superset that the supports constructs necessary to allow C++ to work as a .NET language. The path of least resistance here is to use Microsoft's free tools and C++/CLI. Or of course since Visual Basic 2008 Express is one of those free tools you could just use the code as is. .NET language interoperability is a feature of the .NET/CLR framework.
Note that if you continue to use Dev-C++, do not put your projcts in "C:\Documents and Settings\semaj\My Documents\". In some circumstances, the toolchain fails with paths containing spaces. Also when posting logs, use the raw text from the "Compile Log" tab, not the filtered text from the "Compiler" tab. Bothe these points are mad in the "PLEASE READ BEFORE POSTING A QUESTION" thread.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i am trying to take a c# chat program tutorial and convert it to c++. But I havent had too much luck finding out actually begin the process.
[code]
// Taken from http://www.devx.com/dotnet/Article/28083
Imports System.Net.Sockets
Imports System.Text
Const portNo = 500
Dim tcpclient As New TcpClient
tcpclient.Connect("127.0.0.1", portNo)
Dim ns As NetworkStream = tcpclient.GetStream
Dim data As Byte() = Encoding.ASCII.GetBytes("Hello")
'---send the text---
ns.Write(data, 0, data.Length)
[/code]
So, I began by using
[code]
[C++]
//take from http://msdn.microsoft.com/en-us/library/system.net.sockets.tcpclient.connect(VS.71).aspx for c++
TcpClient* tcpClient = new TcpClient();
tcpClient->Connect("127.0.0.1", 500);
[/code]
and it returns
165 C:\Documents and Settings\semaj\My Documents\Projects\UnkIM\UnkIM.cpp `TcpClient' undeclared (first use this function)
165 C:\Documents and Settings\semaj\My Documents\Projects\UnkIM\UnkIM.cpp `tcpClient' undeclared (first use this function)
165 C:\Documents and Settings\semaj\My Documents\Projects\UnkIM\UnkIM.cpp `TcpClient' has not been declared
//-----------------------------------
I am not sure what i am to include or if it is even possible to use this in devc++. any ideas? Thanks.
Related
Code: code
The problem with VB.NET or even C# code is that it requires th .NET framework and Common Language Runtime(CLR). Dev-C++ (or specifically GCC) supports neither.
Microsoft's C++ compiler supports C++/CLI a C++ superset that the supports constructs necessary to allow C++ to work as a .NET language. The path of least resistance here is to use Microsoft's free tools and C++/CLI. Or of course since Visual Basic 2008 Express is one of those free tools you could just use the code as is. .NET language interoperability is a feature of the .NET/CLR framework.
Microsoft Visual Studio Express Editions can be found here: http://www.microsoft.com/express/product/default.aspx
If you still want plain C++, and wish to use Dev-C++, you will have to use the lower level WinSock API directly. http://msdn.microsoft.com/en-us/library/ms740673(VS.85).aspx
Note that if you continue to use Dev-C++, do not put your projcts in "C:\Documents and Settings\semaj\My Documents\". In some circumstances, the toolchain fails with paths containing spaces. Also when posting logs, use the raw text from the "Compile Log" tab, not the filtered text from the "Compiler" tab. Bothe these points are mad in the "PLEASE READ BEFORE POSTING A QUESTION" thread.
Clifford
actually, my mistake, i believe its vb....it just said ".net" so I assumed it was C#.