Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JAVA NIO TCP SOCKET ÁÄÌìȺ·¢

ÒÔÇ°¶¼ÊÇÓÃÒ»°ãµÄsocket±à³Ì£¬ÓÃÏß³ÌÀ´¿ØÖÆ¡£×î½üͻȻÓÃnioÀ´×öЩ¶«Î÷¡£
nioµÄºÃ´¦ÎÒÀ´ËµÒ»Ï£ºµÚÒ»£¬¶Áд¶¼ÊÇ»ùÓÚ¿éµÄ£¬Ð§Âʸߡ£µÚ¶þ£¬Í¨¹ýÒýÈëselector,¼ò»¯ÁËÍøÂç±à³ÌÄ£ÐÍ£¬Òì²½·Ç×èÈû¡£
¼ÈÈ»ÓÐÕâô¶àºÃ´¦£¬ÄǾÍд¸öNIO TCPÍøÂçÁÄÌìÊÒÀ´Á·Á·ÊÖ°É¡£
ÒòΪûÓÐдgui£¬ÊÇ»ùÓÚ¿ØÖÆ̨µÄËùÒÔûд˽Á˵IJ¿·Ö£¬Ö»Ð´Á˹«¹²ÁÄÌìÊÒ¡££¨Æäʵ£¬¼ÈÈ»ÊÇ·þÎñÆ÷¶Ë¿ÉÒÔ·Ö·¢¸øËùÓÐÈË£¬·Ö·¢¸øÌض¨ÈËÒ²ÊǺÜÈÝÒ×ʵÏֵġ£
×¢Ò⣺ÕâÀïÖ»ÊÇΪÁËÁ·ÊÖ£¬ÁªÏµ·þÎñÆ÷¶Ë·Ö·¢ÏûÏ¢µ½¸÷¸ö¿Í»§¶Ë¡£TCP À´Ð´ÁÄÌìÊÒ£¬ÔÚÏÖʵÖÐÊDz»¿ÉÈ¡µÄ¡£IM¶¼ÊÇ»ùÓÚUDPÀ´Ð´µÄ¡£
ÏÈÉÏ´úÂë°É¡£
·þÎñÆ÷¶Ë´úÂë MySocketServer.java
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kevin.nio;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.Date;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
 *
 * @author kevin
 */
public class MySocketServer implements Runnable{
  
    private boolean running;
   
    private Selector selector;
    String writeMsg;
    StringBuffer sb=new StringBuffer();
    SelectionKey ssckey;
    public MySocketServer(){
       
        running=true;
       
    }
    public void init(){
        try {
            selector = Selector.open();
            ServerSocketChannel ssc = ServerSocketChannel.open();
         &nbs


Ïà¹ØÎĵµ£º

java ½â¾öԼɪ·òÎÊÌâ

package Pack;
import java.text.*;
import java.util.*;
import java.text.DecimalFormat;
import java.util.*;
public class Test {
/**
* @param args
*/
public static void main(String args[]) {

yuesef(50,3);
}
public static void yuesef(int n, int m) {
ArrayList<Integer ......

ÔËÓüÓÃܼ¼Êõ±£»¤JavaÔ´´úÂë

       ÔËÓüÓÃܼ¼Êõ±£»¤JavaÔ´´úÂë
       
java
³ÌÐòµÄÔ´´úÂëºÜÈÝÒ×±»±ðÈË͵¿´¡£Ö»ÒªÓÐÒ»¸ö·´±àÒëÆ÷£¬ÈκÎÈ˶¼¿ÉÒÔ·ÖÎö±ðÈ˵ĴúÂë¡£±¾ÎÄÌÖÂÛÈçºÎÔÚ²»ÐÞ¸ÄÔ­ÓгÌÐòµÄÇé
¿öÏ£¬Í¨¹ý
¼ÓÃÜ
¼¼Êõ±£»¤Ô´´ú
Âë¡£
¡¡¡¡Ò»¡¢ÎªÊ²Ã´Òª
¼ÓÃÜ
£¿

¡¡ ......

¹²ÏíÄÚ´æÔÚJavaÖÐʵÏÖºÍÓ¦ÓÃ

¹²ÏíÄÚ´æÔÚJavaÖÐʵÏÖºÍÓ¦ÓÃ
Õª×Ôhttp://zc4530.javaeye.com/blog/326186 
1¡¢¹²ÏíÄÚ´æ¶ÔÓ¦Ó¦Óÿª·¢µÄÒâÒå
¶ÔÊìÖªUNIXϵͳӦÓÿª·¢µÄ³ÌÐòÔ±À´Ëµ£¬IPC£¨InterProcess Communication£©»úÖÆÊǷdz£ÊìϤµÄ£¬IPC»ù±¾°üÀ¨¹²ÏíÄÚ´æ¡¢ÐźŵƲÙ×÷¡¢ÏûÏ¢¶ÓÁС¢ÐźŴ¦ÀíµÈ²¿·Ö£¬ÊÇ¿ª·¢Ó¦ÓÃÖзdz£ÖØÒªµÄ±Ø²»¿ÉÉٵŤ¾ß¡£ÆäÖй²Ï ......

JavaÓïÑÔѧУµÄΣÏÕÐÔ£¨ÒëÎÄ£©


¾õµÃÁôÑÔºÜÓеÀÀí£¬ÎÄÕºÜÕÜÀí£¬Ò»²¢×ªÔØ ½¨Òé¶ÁÕß¿´Ô­ÎĵØÖ·
×÷Õߣº ÈîÒ»·å
ÈÕÆÚ£º 2008Äê12Ô 7ÈÕ
ÏÂÃæµÄÎÄÕÂÊÇMore Joel on SoftwareÒ»ÊéµÄµÚ8ƪ¡£
ÎÒ¾õµÃ·­ÒëÄѶȺܴó£¬ÕûÕûÁ½¸ö¹¤×÷ÈÕ£¬Ã¿Ìì8СʱÒÔÉÏ£¬²ÅÒë³öÁË5000×Ö¡£³ýÁËJoel´óÁ¿Ê¹ÓÃÙµÓÁíÒ»¸öÔ­ÒòÊÇÔ­ÎÄÉæ¼°"±à³ÌÔ­Àí"£¬ºÃ¶à¶«Î÷ÎÒ¸ù±¾²»¶®¡£Ï£ ......

JAVAÁ¬½ÓÊý¾Ý¿â´óÈ«

JAVAÁ¬½ÓÊý¾Ý¿â´óÈ«
 
 
1£®Oracle8/8i/9iÊý¾Ý¿â£¨thinģʽ£©
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:ts"; //tsΪÊý¾Ý¿âµÄSID
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,u ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ