std::string Tools::getcurrTime(){ #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) struct timeval now; ...
分类:
其他好文 时间:
2014-10-10 16:49:23
阅读次数:
484
原型intselect(intnfds,fd_set*readfds,fd_set*writefds,fd_set*exceptfds,const struct timeval*timeout);nfds:本参数忽略,仅起到兼容作用。 readfds:(可选)指针,指向一组等待可读性检查的套接口。 ...
分类:
其他好文 时间:
2014-09-22 16:15:42
阅读次数:
319
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
int poll(struct pollfd *fds, nfds_t nfds, int timeout);
int epoll_wait(int epfd, struct...
分类:
其他好文 时间:
2014-09-17 23:23:42
阅读次数:
325
一、selectwinsock中#include 原型intselect(intnfds,fd_set*readfds,fd_set*writefds,fd_set*exceptfds,const struct timeval*timeout);nfds:本参数忽略,仅起到兼容作用。readfds:...
分类:
其他好文 时间:
2014-09-17 02:19:01
阅读次数:
298
测试机器处理效率,或者做效率优化的适合: 1 #include 2 #include 3 void getCurrentTime(char* buf) 4 { 5 struct timeval tv; 6 7 struct timezone tz; 8 9...
分类:
其他好文 时间:
2014-09-02 19:43:05
阅读次数:
205
/**
* TCP,使用非阻塞 connect
**/
#include "unp.h"
int
connect_nonb(int sockfd, const SA *saptr, socklen_t salen, int nsec)
{
int flags, n, error;
socklen_t len;
fd_set rset, wset;
struct timeval tval;
//1.调用 fcntl 设置套接字为非阻塞
flags = Fcntl(sockfd, ...
分类:
其他好文 时间:
2014-08-24 23:57:13
阅读次数:
464
static voidseedrand (){ struct timeval tv; gettimeofday (&tv, NULL); sbrand (tv.tv_sec ^ tv.tv_usec ^ getpid ());}上述是bash中生成随机数的代码,处理是非常的简单,秒 (tv.tv_s...
分类:
其他好文 时间:
2014-08-20 22:34:52
阅读次数:
206
#include #include #include /* accurate to usec*/void getusertime(){ static struct timeval tpstart,tpend; static float timeuse; static...
分类:
其他好文 时间:
2014-08-19 12:26:34
阅读次数:
192
笔记:在linux应用程序中延时有sleep()、msleep()和usleep()函数之类的延时,也有如下形式的延时: struct timeval delay;
delay.tv_sec = sleepSecond;
delay.tv_usec = 0;
select( 0, NULL, NULL, NULL, &delay );但是基本上都是基于进程休眠的,好像...
分类:
系统相关 时间:
2014-08-11 18:06:32
阅读次数:
323
关于Linux下时间编程的问题:1. Linux下与时间有关的结构体struct timeval{int tv_sec;int tv_usec;};其中tv_sec是由凌晨开始算起的秒数,tv_usec则是微秒(10E-6 second)。struct timezone{int tv_minut.....
分类:
系统相关 时间:
2014-08-06 11:35:41
阅读次数:
313