上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 22 下一页
摘要: 一直觉得没写的必要,但还是记一下吧。太书面化记不住,就简单些下。类型转换分为隐式类型转换和强制类型转换。隐式类型转换是编译器自动执行,无需程序员介入。如下://算术转换double b = 5 + 3;//条件表达式int val = 0;if (val)......强制转换就是要在代码中写明的转换... 阅读全文
posted @ 2014-01-15 16:08 春文秋武 阅读(129) 评论(0) 推荐(0) 编辑
摘要: Redis 是完全开源免费的,遵守BSD协议,先进的key - value持久化产品。它通常被称为数据结构服务器,因为值(value)可以是 字符串(String), 哈希(Map), 列表(list), 集合(sets) 和 有序集合(sorted sets)等类型。redis客户端连接比较简单... 阅读全文
posted @ 2013-12-24 16:31 春文秋武 阅读(355) 评论(0) 推荐(0) 编辑
摘要: 在服务开发过程中,常常需要单例来保存全局资源,本文给出一个实用的实现方案。 使用: 阅读全文
posted @ 2013-12-18 17:23 春文秋武 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 多线程下,常常会使用互斥锁或者读写锁来确保临界区的正确使用。pthread_mutex_lock(&mutex);//using critical sectionpthread_mutex_unlock(&mutex);如果在使用临界区期间发生异常返回,导致锁没有释放。为了防止这种现象发生,我们通常... 阅读全文
posted @ 2013-12-18 17:08 春文秋武 阅读(258) 评论(0) 推荐(0) 编辑
摘要: 1. 常用函数#include //open a directory//failed-NULL, other-return a DIR streamDIR *opendir (const char* path_name);//close the directory stream//0 succeed... 阅读全文
posted @ 2013-11-21 17:33 春文秋武 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 一个比较实用的连接函数,支持host为域名。#include #include #include #include #include #include #include #include using namespace std;int my_connect(const char *host, int... 阅读全文
posted @ 2013-11-21 14:39 春文秋武 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 实例:client#include #include #include #include const int MAXLINE = 100;void str_cli(int sockfd) { char recvline[MAXLINE]; string str; getline(cin, st... 阅读全文
posted @ 2013-10-18 15:10 春文秋武 阅读(241) 评论(0) 推荐(0) 编辑
摘要: #include pid_t gettid(){ return syscall(SYS_gettid); } 阅读全文
posted @ 2013-09-17 17:36 春文秋武 阅读(470) 评论(0) 推荐(0) 编辑
摘要: 动态链接库(.so)可以让程序在运行时被加载,当so修改时,使用程序不需要重新编译就可以使用。本文介绍几个函数,讲述so的加载和方法调用。void * dlopen( const char * pathname, int mode);以指定模式打开某动态链接库文件,返回句柄。模式有:RTLD_LAZ... 阅读全文
posted @ 2013-09-06 17:46 春文秋武 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 1.unixtime和可读时间的转换unixtime是距"1970-01-01 08:00:00"的时间秒数unixtime -> readableselect from_unixtime(double,format)readable -> unixtimeselect unix_timestamp... 阅读全文
posted @ 2013-09-06 15:30 春文秋武 阅读(111) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 22 下一页