// : implementation file
//
#include ""
#include ""
#include ""
extern CSerialPort m_Ports;
// CServer
extern CPtrArray gSocketArr;
extern bool gbIsConnected;
CServer::CServer():mStrSendBuf("")
{
//bIsConnectFlash = false;
}
CServer::~CServer()
{
}
// CServer member functions
void CServer::OnAccept(int nErrorCode)
{
// TODO: Add your specialized code here and/or call the base class
if(0 == nErrorCode)
{
CServer * pSocket = new CServer();
if(SOCKET_ERROR != this->Accept(*pSocket))
{
(pSocket);
}
else
{
::AfxMessageBox(_T("Accept->Error"));
}
pSocket = NULL;
}
CAsyncSocket::OnAccept(nErrorCode);
}
void CServer::OnReceive(int nErrorCode)
{
// TODO: Add your specialized code here and/or call the base class
if(0 == nErrorCode)
{
char buf[30] = {0};
int nRead = this->Receive(buf, 30);
if(0 != nRead && SOCKET_ERROR != nRead)
{
//
// debug info
//
std::fstream debug;
(_T(""), std::ios::app);
int yvalue;
if(debug.is_open())
{
debug<<buf<<"\n";
yvalue = atoi(buf);
//m_Ports.WriteToPort(
}
();
if(0 == strcmp("<policy-file-request/>", buf))
{
std::string strXML = "<cross-domain-policy>";
strXML += "<allow-access-from domain=\"*\"to-ports=\"*\"/>";
//strXML += "<allow-access-from domain=\"localhost\"to-ports=\"1025,9999\"/>";
strXML += "</cross-domain-policy>";
strXML += "\0\0";
this->Send(strXML.c_str(), (int)() + 1);
gbIsConnected = true;
}
else if(0 == strcmp("Connected", buf))
{
////::AfxMessageBox(_T("Hello"));
gbIsConnected = true;
}
}
}
CAsyncSocket::OnReceive(nErrorCode);
}
void CServer::SendData()
{
if(0 == ())
{
for(int i = 0; i < (); i++)
{
((CServer *)gSocketArr[i])->Send(mStrSendBuf.c_str(), (int)() + 1);
}
std::fstream debug;
(_T(""), std::ios::app);
int yvalue;
if(debug.is_open())
{
debug<<mStrSendBuf<<"\n";
}
();
}
else
{
::AfxMessageBox(_T("Socket Error"));
}
}