小编Chr*_*_vr的帖子

udp丢包和恢复

我正在开发基于 udp/tcp 的 P2P 文件和实时视频流应用程序。该应用程序将使用 C++ 为 Linux 和 Windows 平台开发。

我们使用 ICE(TCP/UDP 打孔)来实现 P2P。虽然 TCP 确保数据包丢失,但对于 UDP,我需要一种体面的方法来确保必须将数据包传送到其他对等方。

  1. 我想知道执行此操作的算法或技术。
  2. 是否有任何免费的 thord 方工具/库可以做。

任何链接和建议将不胜感激?

p2p udp network-programming hole-punching

1
推荐指数
1
解决办法
4897
查看次数

std :: vector的最大大小

我在我的代码中使用向量

    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)

c++ stl

1
推荐指数
2
解决办法
3543
查看次数

清除列表中元素的问题

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(); 我在这里做错了吗?请建议我这个

c++

1
推荐指数
1
解决办法
58
查看次数

警告C6269:操作顺序可能不正确:取消引用被忽略

我对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)

c++ code-analysis visual-c++ visual-c++-2010

1
推荐指数
1
解决办法
556
查看次数

在 Java 脚本中访问 ConfigurationManager.AppSettings

我在 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)

javascript asp.net

1
推荐指数
1
解决办法
2万
查看次数

关于多生产者单一消费者问题的信号量

我需要就C++的这个案例研究提出建议.

我已经采用了Queue,其中有多个Thread 20 Producer线程在其上写入.有一个Consumer线程,它将从队列中读取并处理它.我打算使用临界区和信号量来实现同步.

AddTail - 在队列中添加消息.RemoveHead - 从队列中删除数据.

我已将队列长度限制为10.

Crtical部分将保护wrting或/ Reading问题.信号量将同步对队列的访问.

让我知道任何其他POssible解决方案.

c++ multithreading

0
推荐指数
1
解决办法
2645
查看次数

擦除矢量元素崩溃程序

为什么下面的代码失败了?

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)

c++

0
推荐指数
1
解决办法
166
查看次数

用C++动态改变指针的大小

我有以下结构

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 ++做?

c++ struct new-operator dynamic-allocation

0
推荐指数
1
解决办法
1597
查看次数

Cull中的Null终止数组

我想在构造函数中创建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的正确方法吗?

这有什么好的选择吗?

c++

0
推荐指数
2
解决办法
1158
查看次数

错误是:“字典对象”没有属性“ ansible_facts”

我正在遍历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)

vars.yml

    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)

ansible ansible-playbook

0
推荐指数
1
解决办法
5313
查看次数