所以,你试试 sleep(1); printf("."); 很长时间也不会输出。还以为是sleep坏了, 添加一个printf("\n")或者fflush(stdout)可以解决。
recv/recvfrom使用的socket句柄如果绑定的是0.0.0.0,那么对于所有的ip都是匹配的,所以说网卡的缓冲去的数据,只要是这个端口的,都可以取出来。另外新网卡插上以后,网卡驱动检查所有ip包,只要是发给自己的,都会放置到自己的缓冲区中。
#include <map> #include <string> #include <stdio.h> int main(void) { std::map<std::string, int> testmap; testmap["12.0.0.0 1234"] = 1; testmap["12.0.0.1 1234"] = 1; std::map<std::string, int>::iterator it = testmap.begin(); char szIp [100]; short sPort = 0; // short or int !? sscanf(it->first.c_str(), "%s %d", szIp, &sPort); ++it; }
错误的代码:
struct timespec abstime = {time(0) + (timeoutMills / 1000), (timeoutMills % 1000) * 1000000}; if (!sem_timedwait(pSem, &abstime)) return 0;
struct timespec abstime; struct timeval tv; gettimeofday(&tv, NULL); abstime.tv_sec = tv.tv_sec + ((timeoutMills*1000 + tv.tv_usec)/1000000); abstime.tv_nsec = ((timeoutMills*1000 + tv.tv_usec) % 1000000)*1000; if (!sem_timedwait(pSem, &abstime)) return 0;
uint32 a = 1, b=2; if ( a - b > 0 ) alert("a>b?"); if ( a > b ) alert("a>b!");
其他情况不是,小于一个字长,需要先读出一个字长,在写回一个字长。 多核处理器即使是对齐的字长区域也不是原子的,因为其他处理器可能使用自己的缓存,使用lock可以保证原子性。原子整数读写是操作系统所有同步和互斥机制的基础。
return (long)(now.tv_sec*1000 + now.tv_usec/1000);正确的代码是
long ms = now.tv_sec; ms *= 1000; ms += now.tv_usec/1000; return ms;有什么差别看出来了吗?
uint64 x = 0x9590BD2B6EF7FE8C; // warning. not long enough! uint64 y = 0x9590BD2B6EF7FE8Cull;
“was created with an older compiler than other objects;” 请禁用连接时代码生成,否则cl生成的代码会被link程序修改。或者所有依赖的库全部统一参数重新编译, e.g. log4c。
cd /d %~dp0 set workpath=%cd% "C:\Program Files (x86)\Debugging Tools for Windows (x86)\windbg.exe" -srcpath "%workpath%\..\src" -y "%workpath%" %SystemRoot%\system32\rundll32.exe "%workpath%\libdecklink.dll" StartPlayback
#ifdef _WIN32 static uint64 getSysTime64once() { uint64 tmNow = 0; struct _timeb timebuffer; _ftime(&timebuffer); tmNow = timebuffer.time; tmNow *= 1000; tmNow += timebuffer.millitm; return tmNow; } static uint64 getSysTime64() { static uint64 initmsec = 0; static LARGE_INTEGER freq; static LARGE_INTEGER now; if (initmsec == 0){ QueryPerformanceFrequency(&freq); QueryPerformanceCounter(&now); initmsec = getSysTime64once(); return initmsec; }else { LARGE_INTEGER testtime; QueryPerformanceCounter(&testtime); return initmsec + static_cast<uint64>(1.0 * (testtime.QuadPart - now.QuadPart)/freq.QuadPart*1000); } } #else static uint64 getSysTime64() { uint64 tmNow = 0; struct timeval tv; gettimeofday(&tv, NULL); tmNow = tv.tv_sec; tmNow *= 1000; tmNow += tv.tv_usec/1000; return tmNow; } #endif
static uint64 getSysTime64() { static DWORD dwProcNum = 0; if (dwProcNum == 0){ SYSTEM_INFO sysInfo; GetSystemInfo(&sysInfo); dwProcNum = sysInfo.dwNumberOfProcessors; } if (dwProcNum > 1){ SetThreadAffinityMask(GetCurrentThread(), 1); } //...(2), 另外系统本地时间也是会漂移,不信的话,运行一个ntpd,然后对比上面的cpu计数得到的时间和ntp修正过的本地时间看看。
uint64 tmNow = 0; struct _timeb timebuffer; _ftime(&timebuffer); tmNow = timebuffer.time; tmNow *= 1000; tmNow += timebuffer.millitm; return tmNow;
如果当前dll目录下有pdb文件,dumpbin会读取并参考导出函数的内部名称。
::test.exe –i %group% –d -f %card% .\test.exe -i %group% -d -f %card%
static int Tvup_SetSockSendBuf(int sockfd, uint32 bufsize) { int sendbuff = bufsize; socklen_t optlen = sizeof(sendbuff); return setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, (char *)&sendbuff, sizeof(sendbuff)); } static int Tvup_SetSockRecvBuf(int sockfd, uint32 bufsize) { int recvbuff = bufsize; socklen_t optlen = sizeof(recvbuff); return setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, (char *)&recvbuff, sizeof(recvbuff)); }
Tvup_SetSockRecvBuf(m_nIncomingUdpSocket, SIZE_1M*2);
HANDLE CreateRecordEvent(void){ #ifdef WIN32 // Initialize a security descriptor. PSECURITY_DESCRIPTOR pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH); if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION)) { return NULL; } // Add the ACL to the security descriptor. if (!SetSecurityDescriptorDacl(pSD, TRUE, // bDaclPresent flag NULL, // All Access By EveryOne FALSE)) // not a default DACL { return NULL; } SECURITY_ATTRIBUTES sa; memset(&sa, 0, sizeof sa); sa.nLength = sizeof(sa); sa.bInheritHandle = false; sa.lpSecurityDescriptor = pSD; HANDLE hEvt = CreateEventA(&sa, FALSE, FALSE, "\\Global\\DeclinkRecordEvent"); return hEvt; #endif return NULL; }
$ ct-ng list-samples Status Sample name [G.X] alphaev56-unknown-linux-gnu [G.X] alphaev67-unknown-linux-gnu [G.X] arm-bare_newlib_cortex_m3_nommu-eabi [G.X] arm-cortex_a15-linux-gnueabi [G..] arm-cortex_a8-linux-gnueabi [G..] arm-davinci-linux-gnueabi [G..] armeb-unknown-eabi [G.X] armeb-unknown-linux-gnueabi [G.X] armeb-unknown-linux-uclibcgnueabi [G..] arm-unknown-eabi [G..] arm-unknown-linux-gnueabi [G.X] arm-unknown-linux-uclibcgnueabi [G.X] armv6-rpi-linux-gnueabi [G.X] avr32-unknown-none [G..] bfin-unknown-linux-uclibc [G..] i586-geode-linux-uclibc [G.X] i586-mingw32msvc,i686-none-linux-gnu [G.X] i686-nptl-linux-gnu [G.X] i686-unknown-mingw32 [G.X] m68k-unknown-elf [G.X] m68k-unknown-uclinux-uclibc [G.X] mips64el-n32-linux-uclibc [G.X] mips64el-n64-linux-uclibc [G.X] mips-ar2315-linux-gnu [G..] mipsel-sde-elf [G..] mipsel-unknown-linux-gnu [G.X] mips-malta-linux-gnu [G..] mips-unknown-elf [G.X] mips-unknown-linux-uclibc [G..] powerpc-405-linux-gnu [G.X] powerpc64-unknown-linux-gnu [G..] powerpc-860-linux-gnu [G.X] powerpc-e300c3-linux-gnu [G.X] powerpc-e500v2-linux-gnuspe [G..] powerpc-unknown_nofpu-linux-gnu [G..] powerpc-unknown-linux-gnu [G..] powerpc-unknown-linux-uclibc [G.X] s390-ibm-linux-gnu [G.X] s390x-ibm-linux-gnu [G..] sh4-unknown-linux-gnu [G..] x86_64-unknown-linux-gnu [G..] x86_64-unknown-linux-uclibc [G.X] x86_64-unknown-mingw32 L (Local) : sample was found in current directory G (Global) : sample was installed with crosstool-NG X (EXPERIMENTAL): sample may use EXPERIMENTAL features B (BROKEN) : sample is currently broken
arch-vendor-kernel-system
27) Women Drivers( sorry, no gender-biase, it's theory about possibility)