日期:2014-05-18 浏览次数:20973 次
MFC定义 CString privacyXml; privacyXml = "<cross-domain-policy>\ <allow-access-from domain=\"*\" to-ports=\"5678\" />\ </cross-domain-policy>"; if(strcmp(clientobj->RecvDataBuf.buf,"<policy-file-request/>") == 0) //请求策略文件 { strcpy(clientobj->RecvDataBuf.buf,privacyXml); SendBytes = sizeof(privacyXml); g_pchatserver->m_Client->optype = OP_IOWrite; if (WSASend(g_pchatserver->m_Client->sclient, &(g_pchatserver->m_Client->RecvDataBuf), 1, &SendBytes, 0, &(g_pchatserver->m_Client->ol), NULL) == SOCKET_ERROR) { if (WSAGetLastError() != ERROR_IO_PENDING) { wsprintf(errormsg,"WSASend() failed with error %d", WSAGetLastError()); ::MessageBox(NULL,errormsg,"Error",MB_OK); return -1; } } break; }
------解决方案--------------------
因为flash在和服务器通信的时候会首先连接843端口,如果连接不上flash就会寻找服务器其它在监听的端口进行连接并且发送<policy-file-request/> \0,这个时候你需要发送策略文件给flash,至于策略文件是什么,"<cross-domain-policy> "+"<allow-access-from domain=\"*\" to-ports=\"1025-9999\"/>"+"</cross-domain-policy> "+(char)0 这个字串就是策略文件的内容,你把这个字串发送给flash就可以了