Skip to content

Commit

Permalink
add tcp and http stack description
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-jingdong committed Nov 6, 2013
1 parent 5a2c614 commit 9fbabe2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
32 changes: 21 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,33 @@ Contains Udp Stack, Tcp Stack and Http Stack.

Udp Stack
---------------------------
When send request, the protocol stack will add two bytes at the beginning of the business data.
It means the length of the business data.
The response data must begin with two bytes of length and business data as well.
The protocol stack will parse the length of the response data to validate the integrity.
After verification, the protocol stack will set pure business data to the matched request.
When send request, the protocol stack will add two bytes at the beginning of the business data.
It means the length of the business data.
The response data must begin with two bytes of length and business data as well.
The protocol stack will parse the length of the response data to validate the integrity.
After verification, the protocol stack will set pure business data to the matched request.

BusMessage must extends the BaseMessge and implements the abstract method in BaseMessage.
The protocol stack will match the request when the response data reach.
The BusMessage must implements the 'match' method to match request via the received business data.
BusMessage must extends the BaseMessge and implements the abstract method in BaseMessage.
The protocol stack will match the request when the response data reach.
The BusMessage must implements the 'match' method to match request via the received business data.


Tcp Stack
---------------------------


Have the same framework with the Udp Stack.

Implements via nio. And have the combine-packet function.


Http Stack
---------------------------
---------------------------
There is a thread pool in the protocol stack(org.wjd.net.http.conn).
POOL_SIZE can be setted via the constructor method.
MAX_SIZE indicate the max request that can be sent at the same time.

The file upload-download function under org.wjd.net.http.file package.


Developed By
=============================================
wu-jingdong - donwujing@163.com
9 changes: 7 additions & 2 deletions src/org/wjd/net/http/conn/HttpChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public abstract class HttpChannel extends Handler
/**
* 默认的请求线程数量
*/
private static final int POOL_SIZE = 2;
private static int POOL_SIZE = 2;

/**
* 最大的请求线程数量
*/
private static final int MAX_SIZE = 5;
private static int MAX_SIZE = 5;

/**
* 请求线程组
Expand All @@ -58,6 +58,11 @@ public abstract class HttpChannel extends Handler
* 正在执行的请求任务
*/
protected List<HttpRequest> doQueue = new ArrayList<HttpRequest>();

public HttpChannel(int poolSize)
{
POOL_SIZE = poolSize;
}

/**
* 发送请求
Expand Down

0 comments on commit 9fbabe2

Please sign in to comment.