我正在开发基于 udp/tcp 的 P2P 文件和实时视频流应用程序。该应用程序将使用 C++ 为 Linux 和 Windows 平台开发。
我们使用 ICE(TCP/UDP 打孔)来实现 P2P。虽然 TCP 确保数据包丢失,但对于 UDP,我需要一种体面的方法来确保必须将数据包传送到其他对等方。
任何链接和建议将不胜感激?
我在我的代码中使用向量
std::vector<CEventLogInfo >
class CEventLogInfo
{
// date and time
unsigned short m_sMonth;
unsigned short m_sDay;
unsigned int m_nYear;
unsigned short m_sHour;
unsigned short m_sMin;
unsigned short m_sSec;
unsigned long m_nGatewayMacID;
unsigned char m_byCommandType;
unsigned char m_byStatus;
unsigned char m_byEventName;
unsigned char m_byDirection;
unsigned short m_nPacketLen;
char* m_pPacket;
// ..some method
}
CEventLogInfo::CEventLogInfo(const CEventLogInfo& refMessage)
{
m_sMonth = refMessage.m_sMonth;
m_sDay = refMessage.m_sDay;
m_nYear = refMessage.m_nYear;
m_sHour = refMessage.m_sHour;
m_sMin = refMessage.m_sMin;
m_sSec = refMessage.m_sSec;
m_nGatewayMacID = refMessage.m_nGatewayMacID;
m_byCommandType = refMessage.m_byCommandType; …
Run Code Online (Sandbox Code Playgroud) struct ScheduleTaskInfo
{
unsigned int nTaskID;
__time64_t timeStartTime;
__time64_t timeEndTime;
};
typedef list<ScheduleTaskInfo> SchedulerList;
SchedulerList::iterator itrSchedulerList;
for(itrSchedulerList = gSchedulerList.begin();itrSchedulerList != gSchedulerList.end();itrSchedulerList++)
{
SYSTEMTIME st;
GetLocalTime(&st);
CTime ctSyatemTime(st);
if (itrSchedulerList->timeEndTime == ctSyatemTime.GetTime())
{
itrSchedulerList = gSchedulerList.erase(itrSchedulerList);
}
}
Run Code Online (Sandbox Code Playgroud)
我这样做它正在崩溃for循环.我认为这是由于erase(); 我在这里做错了吗?请建议我这个
我对vs 2010上的c ++代码运行代码分析我在这些行上遇到错误
va_arg(argList, TCHAR_ARG);
va_arg(argList, int*);
Run Code Online (Sandbox Code Playgroud)
警告C6269:操作顺序可能不正确:取消引用被忽略
在这两条线路上收到警告的原因是什么?
我在Switch案件上遇到错误
case 'C':
case 'C'|_atltmpFORCE_ANSI:
case 'C'|_atltmpFORCE_UNICODE:
case 'o';
case 'p':
case 'n':
Run Code Online (Sandbox Code Playgroud)
完整的代码
inline void CXString::FormatV(LPCTSTR lpszFormat, va_list argList)
{
va_list argListSave = argList;
// make a guess at the maximum length of the resulting string
int nMaxLen = 0;
for (LPCTSTR lpsz = lpszFormat; *lpsz != '\0'; lpsz = CharNext(lpsz))
{
// handle '%' character, but watch out for '%%'
if (*lpsz != '%' || *(lpsz = CharNext(lpsz)) == …
Run Code Online (Sandbox Code Playgroud) 我在 aspx 文件中有这段 JavaScript 代码
页面.aspx
<asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="server">
----some code----
added after suggestion from Satpal
<script type="text/javascript">
var GAAccountId = '<%=ConfigurationManager.AppSettings["GAAccountId"]%>';
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<%--<script type="text/javascript">
debugger;
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '<%=ConfigurationManager.AppSettings["GAAccountId"]%>']);
_gaq.push(['_setDomainName', 'auto']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview', '/Register']);
_gaq.push(['_trackPageLoadTime']);
(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>--%>
</asp:Content> …
Run Code Online (Sandbox Code Playgroud) 我需要就C++的这个案例研究提出建议.
我已经采用了Queue,其中有多个Thread 20 Producer线程在其上写入.有一个Consumer线程,它将从队列中读取并处理它.我打算使用临界区和信号量来实现同步.
AddTail - 在队列中添加消息.RemoveHead - 从队列中删除数据.
我已将队列长度限制为10.
Crtical部分将保护wrting或/ Reading问题.信号量将同步对队列的访问.
让我知道任何其他POssible解决方案.
为什么下面的代码失败了?
typedef vector<SOCKET /*socket*/> UIConnection;
UIConnection::iterator itrUICon;
for ( itrUICon = m_ListUIConnection.begin();itrUICon != m_ListUIConnection.end();itrUICon++)
{
if (*itrUICon == nSock)
{
itrUICon = m_ListUIConnection.erase(itrUICon);
}
}
Run Code Online (Sandbox Code Playgroud) 我有以下结构
typedef struct DeviceInfo
{
char[30] name;
char[30] serial Number;
}DeviceInfo;
I am doing this
DeviceInfo* m_DeviceInfo = new DeviceInfo[4];
// Populate m_DeviceInfo
Run Code Online (Sandbox Code Playgroud)
然后我想重新调整大小m_DeviceInfo
为6,并希望保留Previous 4 Value.
怎么用c ++做?
我想在构造函数中创建NULL终止数组.
class Test
{
char name [30];
char Address[100]
};
Test::Test()
{
memset(name ,0, 30);
memset(Address, 0, 100);
}
Run Code Online (Sandbox Code Playgroud)
这是将数组初始化为NULL的正确方法吗?
这有什么好的选择吗?
我正在遍历yml文件并过滤并将那些微服务元数据保留在传递的命令行参数中的列表中
ansible-playbook -i inventory/inventory sp-deployer.yml --ask-vault-pass --extra-vars '{"microservices_list":[iwan,csrservice]}'
Run Code Online (Sandbox Code Playgroud)
最后,根据上述标准,我需要从yml文件中获得这三个值。为此我创建了一个ansible sp-deployer.yml。我使用set_facts创建了动态列表。第一个列表可以正常工作,但是当我创建第二个列表时它失败。请帮助我。其他建议对我也很好。
name: "ms_service"
port: "830"
streams: "noti,jk-noti"
Run Code Online (Sandbox Code Playgroud)
version: 1
name: user
jobs:
ns1:
ip: "1.1.1.1"
ns_version: "4.2"
f_packs:
- f-pack-1:
name: "pack1"
microservices:
- microservice-1:
name: "ms_service"
port: "830"
streams: "noti,jk-noti"
- microservice-2:
name: "ms_service1"
port: "830"
streams: "noti1,jk-noti1"
- f-pack-2:
name: "pack4"
microservices:
- microservice-1:
name: "ms_service3"
port: "830"
streams: "noti,jk-noti3"
- microservice-2:
name: "ms_service4"
port: "830"
streams: "noti,jk-noti4"
- microservice-3:
name: "ms_service5"
port: "830"
streams: "noti,jk-noti5"
Run Code Online (Sandbox Code Playgroud)
脚本:sp-deployer.yml
--- …
Run Code Online (Sandbox Code Playgroud) c++ ×7
ansible ×1
asp.net ×1
javascript ×1
new-operator ×1
p2p ×1
stl ×1
struct ×1
udp ×1
visual-c++ ×1