08 2013 档案
摘要:今天又写了delete的部分,时间就这么被一天天地浪费了,我感到十分惋惜呀 1 #pragma once 2 #include "stdio.h" 3 4 struct Node 5 { 6 Node(int aValue) 7 :m_Value(aValue) 8 ,m_pLeft(NULL) 9 ,m_pRight(NULL)10 ,m_pParent(NULL)11 {12 13 }14 int m_Value;15 Node* m_pLeft;16 Node* m_pRig...
阅读全文
摘要:http://codemacro.com/2012/08/29/mmo-chat-server/
阅读全文
摘要:之前写的服务器端 表示都无法收到client发的数据,找不到原因,原来是有个socket接收数据缓冲木有设置,现在设置后就可以正常收到数据啦!server端:#include #include #include #pragma comment(lib, "ws2_32.lib")#define MYPORT 1234 // the port users will be connecting to#define BACKLOG 5 // how many pending connections queue will hold#define BUF_SIZE 200int fd
阅读全文
摘要:用select的时候 设置超时时间 就有一些数据收不到,当设置为轮询就可以啦。这不科学啊!为毛?#include #include #include #pragma comment(lib, "ws2_32.lib")#define MYPORT 1234 // the port users will be connecting to#define BACKLOG 5 // how many pending connections queue will hold#define BUF_SIZE 200int fd_A[BACKLOG]; // accepted connec
阅读全文
摘要:算法导论第10章的东西,感觉用双链表真心简单,就是有点浪费空间,但是时间复杂度O(1):#include struct LinkNode{ LinkNode(): m_Value(-1) , m_pPreNode(NULL) , m_pNextNode(NULL) { } int m_Value; LinkNode* m_pPreNode; LinkNode* m_pNextNode;};class Queue{public: void Init() { m_pHeadNode = new LinkNod...
阅读全文
摘要:慢慢修改:#include #include #include #define PORT 5010#define MSGSIZE 1024int BytesSum = 0;#pragma comment(lib, "ws2_32.lib")DWORD WINAPI WorkerThread(LPVOID lpParameter);void InitWinSocket() { WSADATA wsaData; WSAStartup(0x0202, &wsaData);}#define ListenQ 10int main(){ InitWinSocke...
阅读全文
摘要:之前光看理论是不行滴,一定要实践,实践啊,不然永远都是门外汉!!嗯嗯,把找到的一段源码贴上先,稍微修改了一下:#include #include #include #define PORT 5010#define MSGSIZE 1024int BytesSum = 0;#pragma comment(lib, "ws2_32.lib")DWORD WINAPI WorkerThread(LPVOID lpParameter);void InitWinSocket() { WSADATA wsaData; WSAStartup(0x0202, &wsaDa...
阅读全文
摘要:之前没有接触过数据库编程,尼玛,面试神码的最恶心了,非得神码都懂点,好吧,最近开始研究下,先从SQLite开始吧,贴上找到SQliteDB。之后搜集资料,慢慢学习!
阅读全文
摘要:大家自己分析吧#pragma once//演示QQ2009#define WINDOW_WIDTH 250 //窗口宽度#define WINDOW_HEIGHT 600 //窗口高度struct xc_image_res //图片资源{ HIMAGE image_bk; HIMAGE hImageLogo; HIMAGE close_leave; HIMAGE close_stay; HIMAGE close_down; HIMAGE max_leave; HIMAGE max_stay; HIMAGE max_down; HIM...
阅读全文
摘要:#pragma once//演示QQ2009#define WINDOW_WIDTH 250 //窗口宽度#define WINDOW_HEIGHT 600 //窗口高度struct xc_image_res //图片资源{ HIMAGE image_bk; HIMAGE hImageLogo; HIMAGE close_leave; HIMAGE close_stay; HIMAGE close_down; HIMAGE max_leave; HIMAGE max_stay; HIMAGE max_down; HIMAGE min...
阅读全文
摘要:#pragma once//演示QQ2009#define WINDOW_WIDTH 250 //窗口宽度#define WINDOW_HEIGHT 600 //窗口高度struct xc_image_res //图片资源{ HIMAGE image_bk; HIMAGE hImageLogo; HIMAGE close_leave; HIMAGE close_stay; HIMAGE close_down; HIMAGE max_leave; HIMAGE max_stay; HIMAGE max_down; HIMAGE min...
阅读全文
摘要:typedef struct min_heap{ struct event** p; unsigned n, a;} min_heap_t;static inline void min_heap_ctor_(min_heap_t* s);static inline void min_heap_dtor_(min_heap_t* s);static inline void min_heap_elem_init_(struct event* e);static inline int min_heap_elt_is_top_...
阅读全文
摘要:从msdn上看二者的解释:postmessage :Places (posts) a message in the message queue associated with the thread that created the specified window and returns without waiting for the thread to process the message.To post a message in the message queue associated with a thread, use thePostThreadMessagefunction.The
阅读全文
摘要:摘自stackflow的回答,主要从架构上说明了二者的区别:As for design philosophy, libev was created to improve on some of the architectural decisions in libevent, for example, global variable usage made it hard to use libevent safely in multithreaded environments, watcher structures are big because they combine I/O, time and
阅读全文
摘要:好吧,神马都init好了,loop毕竟是个环呐,在哪跑起来呢,ok,他是ev_run的工作:int ev_run (EV_P_ int flags){#if EV_FEATURE_API ++loop_depth;#endif assert (("libev: ev_loop recursion during release detected", loop_done != EVBREAK_RECURSE)); loop_done = EVBREAK_CANCEL; EV_INVOKE_PENDING; /* in case we recurse, ensure orderi
阅读全文
摘要:#define ev_io_init(ev,cb,fd,events) / do { ev_init ((ev), (cb)); ev_io_set ((ev),(fd),(events)); } while (0)/看到没,这就是C语言的恶心指出,尼玛找个定一点都要用全局搜索字符,才找到这个宏。好吧,看它都做了写神马东东:ev_init ((ev), (cb));就是把watcher进行初始化,把回调设置进去;ev是神马玩意呢,就是ev_io:/* invoked when fd is either EV_READable or EV_WRITEable *//* reven...
阅读全文
摘要:/* these may evaluate ev multiple times, and the other arguments at most once *//* either use ev_init + ev_TYPE_set, or the ev_TYPE_init macro, below, to first initialise a watcher */#define ev_init(ev,cb_) do { \ ((ev_watcher *)(void *)(ev))->active = \ ((ev_watcher *)(void *)(ev))...
阅读全文
摘要:尼玛 C语言学不好真是桑心呐!看了libev的代码有一种想死的感觉,但是还是要硬着头皮看下去,一定看完!/* initialise a loop structure, must be zero-initialised */static void loop_init ( unsigned int flags){ if (!loop->backend) { origflags = flags;#if EV_USE_REALTIME if (!have_realtime) { struct timespec ts; if ...
阅读全文
摘要:libev作为优秀的高性能IO框架,非常值得学习!虽然我是菜鸟,但也必须学习啦,从今天一点一点地学习,慢慢进步!# include "ev.h"struct event_base;//定义事件类型码,注意啦,都是2的指数幂#define EVLIST_TIMEOUT 0x01#define EVLIST_INSERTED 0x02#define EVLIST_SIGNAL 0x04#define EVLIST_ACTIVE 0x08#define EVLIST_INTERNAL 0x10#define EVLIST_INIT 0x80//定义回调函数typedef void
阅读全文