基于TCP(面向连接)的Socket编程一、客户端:1、打开一个套接字(Socket);2、发起连接请求(connect);3、如果连接成功,则进行数据交换(read、write、send、recv);4、数据交换完成,关闭连接(shutdown、close);二、服务器端:1、打开一个套接字(So...
Follow up for "Search in Rotated Sorted Array":
What if duplicates are allowed?
Would this affect the run-time complexity? How and why?
Write a function to determine if a given target is in the...
分类:
其他好文 时间:
2014-08-26 17:19:16
阅读次数:
191
利用数组做为地图,利用数字为各种元素,用简单的语句做出推箱子的效果。staticvoidMain(string[]args){Console.Write("第一关,请按空格键开始");//程序开始,在屏幕上显示这个提醒,然后下面就开始读取键盘输入的按键:ConsoleKeyInfocf=Consol...
分类:
其他好文 时间:
2014-08-26 17:10:06
阅读次数:
363
skynet 利用内置的原子操作来实现的一个读写锁,重点是理解 ”full memory barrier“ ,UNPv2 中利用互斥和条件变量实现的读写锁。前者是在硬件支持的情况下,显得简单明了,站的层次不一样。
源码贴出来:
struct rwlock {
int write;
int read;
};
static inline void
rwlock_in...
分类:
Web程序 时间:
2014-08-26 11:43:26
阅读次数:
284
在TCP连接开始到结束连接,之间可能会多次传输数据,也就是服务器和客户端之间可能会在连接过程中互相传输多条消息。理想状况是一方每发送一条消息,另一方就立即接收到一条,也就是一次write对应一次read。但是,现实不总是按照剧本来走。MINA官方文档节选:TCP guarantess deliver...
分类:
Web程序 时间:
2014-08-26 11:02:47
阅读次数:
346
Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be o...
分类:
其他好文 时间:
2014-08-26 00:18:35
阅读次数:
290
//二分法查询 Console.Write("请输入数据个数:"); int n = Convert.ToInt32(Console.ReadLine()); int[] no = new int[n]; ...
分类:
其他好文 时间:
2014-08-25 13:16:04
阅读次数:
201
缓冲的几个基本概念
缓冲的作用:减少系统read和write的次数。
全缓冲
系统标准I/O缓冲区被写满时才进行真正的I/O操作。
磁盘文件一般使用全缓冲
全缓冲使用malloc来分配缓冲区
行缓冲
系统遇到换行符时进行真正的I/O操作。
Te...
分类:
其他好文 时间:
2014-08-25 11:57:14
阅读次数:
214
In concurrent programming, an operation (or set of operations) is atomic, linearizable, indivisible or uninterruptible if
it appears to the rest of the system to occur instantaneously. Atomicity is ...
分类:
其他好文 时间:
2014-08-25 11:52:54
阅读次数:
331
//降序排序 Console.Write("请输入数据的个数:"); int n = Convert.ToInt32(Console.ReadLine()); int []sz=new int[n]; ...
分类:
其他好文 时间:
2014-08-25 01:02:03
阅读次数:
267