So I am trying to write a tic tac toe program that runs through a server. The tic tac toe works fine, but when I try to compile the server on Debian Linux machine, we get many errors starting off with "invalid preprocessing directive #using"
//for server client functionality:
#using <System.dll>
using namespace System;
using namespace System::IO;
using namespace System::Net;
using namespace System::Net::Sockets;
using namespace System::Text;
using namespace System::Threading;
bool CheckWinner(int, int [][3]);
void DoUserMove(int, int&, int [][3]);
void DrawBoard(int [][3]);
void InitBoard(int [][3]);
string str="";
string ConvertToString(int [][3]);
int GetIntVal(string strConvert);
//------------------------------------------------------------------------------------------
//Converting a string of the tic tac toe numbers to integers
class BadConversion : public runtime_error {
public:
BadConversion(const string& s)
: runtime_error(s)
{ }
};
inline int convertToInt(const string& s)
{
istringstream i(s);
int x;
if (!(i >> x))
throw BadConversion("convertToDouble(\"" + s + "\")");
return x;
}
//------------------------------------------------------------------------------------------
void ServerFunction() {
try {
//set tcpListener on port 13000
Int32 port=13000; //int32 is a data type similar to int
IPAddress^ localAddr=IPAddress::Parse("192.168.2.114"); //server ip
// | class that | provides an ip address
// converts ip string to IPAddress instance
// ^ (caret) is a reference to a managed .NET object (a handle)
//tcpListener* server=new TcpListener(port);
TcpListener^ server=gcnew TcpListener(localAddr, port);
//gcnew creates an instance of a managed type on the garbage collected heap
//start listening for client requests
server->Start();
//buffer for reading data
array<Byte>^bytes=gcnew array<Byte>(256); //can send 256 bytes for a segment, but can send as much as we want
String^ data=nullptr;
//enter the listening loop
while (true) {
Console::Write("Waiting for a connection... ");
//perform a blocking call to accept requests
//can also use server.AcceptSocket() here
TcpClient^ client=server->AcceptTcpClient();
Console::WriteLine("Connected!");
data=nullptr;
//get a stream object* for reading and writing
NetworkStream^ stream=client->GetStream();
Int32 i;
//loop to receive all data sent by the client
while (i=stream->Read(bytes, 0, bytes->Length)) {
//translate data bytes to ascii string*
data=Text::Encoding::ASCII->GetString(bytes, 0, i);
Console::WriteLine("Received: {0}", data);
//process data sent by the client
data=data->ToUpper();
array<Byte>^msg=Text::Encoding::ASCII->GetBytes(data);
//send back a response
stream->Write(msg, 0, msg->Length);
Console::WriteLine("Sent: {0}", data);
}
//shutdown and end connection
client->Close();
}
}
catch (SocketException^ e)
{
Console::WriteLine("SocketException: {0}", e);
}
Console::WriteLine("\nHit enter to continue...");
Console::Read();
}
It doesn't like the #using <system.dll> a
Any suggestions?