??xml version="1.0" encoding="utf-8" standalone="yes"?>国产在线观看免费网站,久久久久久中文字幕,欧美zzoohttp://www.aygfsteel.com/hwpok/category/49497.htmlDEBUG - 天道酬勤zh-cnFri, 21 Oct 2011 19:08:37 GMTFri, 21 Oct 2011 19:08:37 GMT60- TCP一点东?/title>http://www.aygfsteel.com/hwpok/archive/2011/10/22/361772.html惠万?/dc:creator>惠万?/author>Fri, 21 Oct 2011 16:51:00 GMThttp://www.aygfsteel.com/hwpok/archive/2011/10/22/361772.htmlhttp://www.aygfsteel.com/hwpok/comments/361772.htmlhttp://www.aygfsteel.com/hwpok/archive/2011/10/22/361772.html#Feedback0http://www.aygfsteel.com/hwpok/comments/commentRss/361772.htmlhttp://www.aygfsteel.com/hwpok/services/trackbacks/361772.htmlpackage org.upeng.mail.net.server;import java.io.BufferedReader;import java.io.Buffered... 阅读全文

]]> - (?MINA2 之IoBuffer http://www.aygfsteel.com/hwpok/archive/2011/09/05/357953.html惠万?/dc:creator>惠万?/author>Sun, 04 Sep 2011 16:40:00 GMThttp://www.aygfsteel.com/hwpok/archive/2011/09/05/357953.htmlhttp://www.aygfsteel.com/hwpok/comments/357953.htmlhttp://www.aygfsteel.com/hwpok/archive/2011/09/05/357953.html#Feedback0http://www.aygfsteel.com/hwpok/comments/commentRss/357953.htmlhttp://www.aygfsteel.com/hwpok/services/trackbacks/357953.html最q做的一个项目用C(jin)开源的C/S应用的服务器框架MINAQ当初做的时候资料非常少Q只能自׃停的试QȝZ(jin)一些规律经验。从|上看的资料上看Q这个服务器框架q是比较E_和支持的q发数还是很不错的,不过... 阅读全文

]]> - (?Mina 框架ȝhttp://www.aygfsteel.com/hwpok/archive/2011/09/04/357931.html惠万?/dc:creator>惠万?/author>Sat, 03 Sep 2011 18:28:00 GMThttp://www.aygfsteel.com/hwpok/archive/2011/09/04/357931.htmlhttp://www.aygfsteel.com/hwpok/comments/357931.htmlhttp://www.aygfsteel.com/hwpok/archive/2011/09/04/357931.html#Feedback0http://www.aygfsteel.com/hwpok/comments/commentRss/357931.htmlhttp://www.aygfsteel.com/hwpok/services/trackbacks/357931.html单介l:(x)MINA框架是对java的NIO包的一个封装,化了(jin)NIOE序开发的隑ֺQ封装了(jin)很多底层的细节,然开发者把_֊集中C务逻辑上来Q最q做?jin)一个相关的目Qؓ(f)?jin)备忘对MINA做一个ȝ?/p>
下面q个startҎ(gu)用来初始化MINAQ?/p>
- private void start(int port, WebContext ctx)
- throws IOException, InstantiationException
- , IllegalAccessException, ClassNotFoundException {
-
- NioSocketAcceptor acceptor = new NioSocketAcceptor(5);
-
- java.util.concurrent.Executor threadPool = Executors.newFixedThreadPool(1500);
-
- acceptor.getFilterChain().addLast("exector", new ExecutorFilter(threadPool));
- acceptor.getFilterChain().addLast("codec",
- new ProtocolCodecFilter(new WebDecoder()Q?span class="keyword">new WebEncoder()));
- LoggingFilter filter = new LoggingFilter();
- filter.setExceptionCaughtLogLevel(LogLevel.DEBUG);
- filter.setMessageReceivedLogLevel(LogLevel.DEBUG);
- filter.setMessageSentLogLevel(LogLevel.DEBUG);
- filter.setSessionClosedLogLevel(LogLevel.DEBUG);
- filter.setSessionCreatedLogLevel(LogLevel.DEBUG);
- filter.setSessionIdleLogLevel(LogLevel.DEBUG);
- filter.setSessionOpenedLogLevel(LogLevel.DEBUG);
- acceptor.getFilterChain().addLast("logger", filter);
-
- acceptor.setReuseAddress(true);
-
- acceptor.getSessionConfig().setReuseAddress(true);
- acceptor.getSessionConfig().setReceiveBufferSize(1024);
- acceptor.getSessionConfig().setSendBufferSize(10240);
-
- acceptor.getSessionConfig().setTcpNoDelay(true);
-
- acceptor.setBacklog(100);
- acceptor.setDefaultLocalAddress(new InetSocketAddress(port));
-
- acceptor.setHandler(new WebHandler());
- acceptor.bind();
- }
NioSocketAcceptor是MINA的适配器,一切都是从q里开始的。MINA中有个过滤器和处理器的概念,qo(h)器用来过滤数据,处理器用来处理数据。具体来说MINA的处理模型就是request->qo(h)器A->qo(h)器B->处理?>qo(h)器B->qo(h)器A->response,q里的request和responsecMserlvet的request和response?/p>
- acceptor.getFilterChain().addLast("exector", new ExecutorFilter(threadPool));
-
- acceptor.getFilterChain().addLast("codec",
- new ProtocolCodecFilter(new WebDecoder()Q?span class="keyword">new WebEncoder()));
-
-
现在详细描述一下request->WebDecoder->WebHandler->WebEncode->response的过E:(x)
客户端发送一个请求到MINA服务器,q里相当于来?jin)一个requet。请求首先来?/p>
- WebDecoderc?实现?jin)ProtocolDecoder接口)中的
- boolean decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception{}Ҏ(gu)
-
-
-
-
-
-
-
-
-
-
然后?/p>
- WebHandler(扩展?jin)IoHandlerAdapter抽象c?中的
- void messageReceived(IoSession session, Object message) throws Exception{}Ҏ(gu)
- WriteFuture future = session.write(response);
- future.addListener(IoFutureListener.CLOSE);
- IoFutureListener里面有个operationComplete(IoFuture future)Ҏ(gu)Q当发送完成之后才调用q个Ҏ(gu)?
-
-
-
-
-
-
然后?/p>
- WebEncoderc?实现?jin)ProtocolEncoder接口)中的
- boolean encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception{}
- Ҏ(gu)
-
-
-
-
-
-
-

]]> - socketPoolhttp://www.aygfsteel.com/hwpok/archive/2011/08/30/357594.html惠万?/dc:creator>惠万?/author>Tue, 30 Aug 2011 10:01:00 GMThttp://www.aygfsteel.com/hwpok/archive/2011/08/30/357594.htmlhttp://www.aygfsteel.com/hwpok/comments/357594.htmlhttp://www.aygfsteel.com/hwpok/archive/2011/08/30/357594.html#Feedback0http://www.aygfsteel.com/hwpok/comments/commentRss/357594.htmlhttp://www.aygfsteel.com/hwpok/services/trackbacks/357594.html
package example.helloword.client;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class SendMsgPool


{
private static SendMsgPool sendMsgPool = new SendMsgPool();
private ExecutorService pool;
private SendMsgPool()

{
pool = Executors.newFixedThreadPool(3);
}
public static SendMsgPool getInstance()

{
return sendMsgPool;
}
public Future<String> sendMsg(String local, int port, String msg)

{
ClinetSocket clientScoket = ClientSocketPool.getInstance()
.getClientSocket(local, port);
ClientTread ct = new ClientTread(clientScoket, msg);
return pool.submit(ct);
}
public void shutDown()

{
this.pool.shutdown();
}
}


]]>- apache mina框架试http://www.aygfsteel.com/hwpok/archive/2011/08/30/357563.html惠万?/dc:creator>惠万?/author>Tue, 30 Aug 2011 05:11:00 GMThttp://www.aygfsteel.com/hwpok/archive/2011/08/30/357563.htmlhttp://www.aygfsteel.com/hwpok/comments/357563.htmlhttp://www.aygfsteel.com/hwpok/archive/2011/08/30/357563.html#Feedback1http://www.aygfsteel.com/hwpok/comments/commentRss/357563.htmlhttp://www.aygfsteel.com/hwpok/services/trackbacks/357563.htmlpackage server;import java.net.InetSocketAddress;import org.apache.mina.core... 阅读全文

]]> - jboss netty 框架试http://www.aygfsteel.com/hwpok/archive/2011/08/30/357562.html惠万?/dc:creator>惠万?/author>Tue, 30 Aug 2011 05:07:00 GMThttp://www.aygfsteel.com/hwpok/archive/2011/08/30/357562.htmlhttp://www.aygfsteel.com/hwpok/comments/357562.htmlhttp://www.aygfsteel.com/hwpok/archive/2011/08/30/357562.html#Feedback0http://www.aygfsteel.com/hwpok/comments/commentRss/357562.htmlhttp://www.aygfsteel.com/hwpok/services/trackbacks/357562.htmlpackage example.helloword.server;import java.net.InetSocketAddress;import ja... 阅读全文

]]> - java 单socket 通信http://www.aygfsteel.com/hwpok/archive/2011/08/26/357328.html惠万?/dc:creator>惠万?/author>Fri, 26 Aug 2011 02:28:00 GMThttp://www.aygfsteel.com/hwpok/archive/2011/08/26/357328.htmlhttp://www.aygfsteel.com/hwpok/comments/357328.htmlhttp://www.aygfsteel.com/hwpok/archive/2011/08/26/357328.html#Feedback0http://www.aygfsteel.com/hwpok/comments/commentRss/357328.htmlhttp://www.aygfsteel.com/hwpok/services/trackbacks/357328.htmlpackage sterning;import java.io.BufferedReader;import java.io.IOException;import... 阅读全文

]]> - [转]JAVA-用HttpClient来模拟浏览器GET,POST http://www.aygfsteel.com/hwpok/archive/2011/08/24/357152.html惠万?/dc:creator>惠万?/author>Tue, 23 Aug 2011 16:08:00 GMThttp://www.aygfsteel.com/hwpok/archive/2011/08/24/357152.htmlhttp://www.aygfsteel.com/hwpok/comments/357152.htmlhttp://www.aygfsteel.com/hwpok/archive/2011/08/24/357152.html#Feedback0http://www.aygfsteel.com/hwpok/comments/commentRss/357152.htmlhttp://www.aygfsteel.com/hwpok/services/trackbacks/357152.html阅读全文

]]> - UDPhttp://www.aygfsteel.com/hwpok/archive/2010/12/25/341528.html惠万?/dc:creator>惠万?/author>Sat, 25 Dec 2010 12:46:00 GMThttp://www.aygfsteel.com/hwpok/archive/2010/12/25/341528.htmlhttp://www.aygfsteel.com/hwpok/comments/341528.htmlhttp://www.aygfsteel.com/hwpok/archive/2010/12/25/341528.html#Feedback0http://www.aygfsteel.com/hwpok/comments/commentRss/341528.htmlhttp://www.aygfsteel.com/hwpok/services/trackbacks/341528.html
while (true)
{
try
{
// 接收数据
datagramSocket.receive(datagramPacket);
String instruction = new String(datagramPacket.getData(), 0, datagramPacket.getLength());
System.out.println(instruction);
String senddStr = "from remote server: " + instruction;
System.out.println("datagramPacket-port: " + datagramPacket.getPort());
System.out.println("datagramPacket-addr: " + datagramPacket.getAddress().getHostAddress());
this.send(datagramPacket.getAddress().getHostAddress(), datagramPacket.getPort(), senddStr);
}
catch (Exception e)
{
e.printStackTrace();
}
}

]]> - java 得到本机所有iphttp://www.aygfsteel.com/hwpok/archive/2010/12/01/339464.html惠万?/dc:creator>惠万?/author>Wed, 01 Dec 2010 00:44:00 GMThttp://www.aygfsteel.com/hwpok/archive/2010/12/01/339464.htmlhttp://www.aygfsteel.com/hwpok/comments/339464.htmlhttp://www.aygfsteel.com/hwpok/archive/2010/12/01/339464.html#Feedback0http://www.aygfsteel.com/hwpok/comments/commentRss/339464.htmlhttp://www.aygfsteel.com/hwpok/services/trackbacks/339464.html
public static String[] getAllLocalHostIP()

{
String[] ret = null;
try

{
String hostName = InetAddress.getLocalHost().getHostName();
if (hostName == null || hostName.length() < 1)

{
return ret;
}
InetAddress[] inetAddresses = InetAddress.getAllByName(hostName);
if (inetAddresses == null || inetAddresses.length < 1)

{
return ret;
}
ret = new String[inetAddresses.length];
for (int i = 0; i < inetAddresses.length; i++)

{
ret[i] = inetAddresses[i].getHostAddress();
}
}
catch (Exception ex)

{
ex.printStackTrace();
}
return ret;
}

]]>
վ֩ģ壺
|
Թ|
Դ|
ɽ|
|
üɽ|
ʼ|
|
ɽ|
|
ϴ|
Ҧ|
ʳ|
|
|
Խ|
ɽ|
|
³|
̨|
|
|
罭|
|
۲|
̩|
ض|
ֶ|
|
|
DZɽ|
|
|
|
|
ɽ|
|
|
̶|
Զ|
ƽ|