FreeBSD中基于ncurses的服务器状态监视器

几个要点

延迟刷新:

struct timeval pre_t;

inline void Refresh()

{

struct timeval cur_t;

gettimeofday( &cur_t, 0 );

if( (cur_t.tv_usec - pre_t.tv_usec ) > 1000*100 )

{

refresh();

pre_t = cur_t;

}

else if( ( cur_t.tv_sec - pre_t.tv_sec ) > 0 )

{

refresh();

pre_t = cur_t;

}

}

功能键获得:

////////////// VT100+

#define VT100+_KEY_F1 0x1b4f50

inline unsigned int getkey( char ch )

{

unsigned int res = ch;

char count=1;

timeout(0);

drawlock.LOCK();

while(ch = getch())

{

if(ch==-1) break;

res = res*256 + ch;

if( ++count > 4 ) continue;

}

drawlock.UNLOCK();

timeout(-1);

return res;

}

使用:key = getkey( getch() )

使用UNIX域:

unlink( sspath.c_str() ); /*server_socket*/

server_sockfd = socket (AF_UNIX, SOCK_STREAM, 0);

server_address.sun_family = AF_UNIX;

strcpy( server_address.sun_path, sspath.c_str() );

server_len = sizeof (server_address);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值