Skip to content

Instantly share code, notes, and snippets.

View luchenqun's full-sized avatar

Luke luchenqun

View GitHub Profile
@luchenqun
luchenqun / server.cpp
Last active November 17, 2017 04:21
libmicrohttpd server
/* Feel free to use this example code in any way
you see fit (Public Domain) */
#include <sys/types.h>
#ifndef _WIN32
#include <sys/select.h>
#include <sys/socket.h>
#else
#include <winsock2.h>
#endif
/*
不同的CPU有不同的字节序类型,这些字节序是指 整数 在内存中保存的顺序,这个叫做 主机序。最常见的有两种:
Little endian:将低序字节存储在起始地址
Big endian:将高序字节存储在起始地址
网络字节顺序是TCP/IP中规定好的一种数据表示格式,它与具体的CPU类型、操作系统等无关,从而可以保证数据在不同主机之间传输时能够被正确解释。网络字节顺序采用big endian排序方式。
int inet_aton(const char *cp, struct in_addr *inp);
将一个字符串IP地址转换为一个32位的网络序列IP地址。如果这个函数成功,函数的返回值非零,如果输入地址不正确则会返回零。认为255.255.255.255是有效的。
in_addr_t inet_addr(const char *cp);
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <netdb.h>
#include <sys/epoll.h>
/*************************************************
* File name : server.c
* Description : 单进程并发服务器
* Author : 745917886@@qq.com
* Version : V1.0
* Date :
* Compiler : arm-linux-gcc-4.4.3
* Target : mini2440(Linux-2.6.32)
* History :
* <author> <time> <version > <desc>

关于Websokket的一些备忘录

任务描述

目前发布合约的过程(truffle) eth_sendTransaction(data):data为合约二进制代码,返回发布交易hash
eth_newBlockFilter():监视新块的产生,返回过滤器索引
eth_getFilterChanges(idx):轮询
eth_getFilterChanges(idx):轮询
......
eth_getFilterChanges(idx):轮询,有结果了,返回相关联的hash

@luchenqun
luchenqun / fset.cpp
Last active December 14, 2017 09:15
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
using namespace std;
class test
{
public:
int v;
/*构造函数*/
test() : v(0) {}
#include <iostream>
using namespace std;
class BirdType //鸟类
{
};
class InsectType //昆虫类
{
};
// 创建 WebSocket 对象
var ws = new WebSocket('wss://localhost:3000/');
// 连接建立时触发
ws.onopen = function() {
console.log('WebSocket已连接');
// 使用连接发送数据
ws.send('Hello!');
};
#include <iostream>
using namespace std;
class InnerClassA
{
public:
InnerClassA() { cout << "in create of InnerClassA" << endl; }
};
class InnerClassB