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

һƪ²»´íµÄ½éÉÜJava Socket±à³ÌµÄÎÄÕÂ

 
ÊÂʵÉÏÍøÂç±à³Ì¼òµ¥µÄÀí½â¾ÍÊÇÁ½Ì¨¼ÆËã»úÏ໥ͨѶÊý¾Ý¶øÒÑ¡£¶ÔÓÚ³ÌÐòÔ±¶øÑÔ£¬È¥ÕÆÎÕÒ»ÖÖ±à³Ì½Ó¿Ú²¢Ê¹ÓÃÒ»ÖÖ±à³ÌÄ£ÐÍÏà¶Ô¾Í»áÏԵüòµ¥µÄ¶àÁË¡£Java SDKÌṩһЩÏà¶Ô¼òµ¥µÄApiÀ´Íê³ÉÕâЩ¹¤×÷£¬Socket¾ÍÊÇÆäÖÐÖ®Ò»¡£
¶ÔÓÚJava¶øÑÔ¡£ÕâЩApi´æÔÚÓëJava.netÕâ¸ö°üÀïÃæ¡£Òò´ËÖ»Òªµ¼ÈëÕâ¸ö°ü¾Í¿ÉÒÔ×¼±¸ÍøÂç±à³ÌÁË¡£ÍøÂç±à³ÌµÄ»ù±¾Ä£Ð;ÍÊÇ¿Í»§»úµ½·þÎñÆ÷Ä£ÐÍ¡£¼òµ¥µÄ˵¾ÍÊÇÁ½¸ö½ø³ÌÖ®¼äÏ໥ͨѶ£¬È»ºóÆäÖÐÒ»¸ö±ØÐëÌṩһ¸ö¹Ì¶¨µÄλÖ㬶øÁíÒ»¸öÔòÖ»ÐèÒªÖªµÀÕâ¸ö¹Ì¶¨µÄλÖ㬲¢È¥½¨Á¢Á½ÕßÖ®¼äµÄÁªÏµ¡£È»ºóÍê³ÉÊý¾ÝµÄͨѶ¾Í¿ÉÒÔÁË¡£ÕâÀïÌṩ¹Ì¶¨Î»ÖõÄͨ³£³ÆΪ·þÎñÆ÷£¬¶ø½¨Á¢ÁªÏµµÄͨ³£½Ð×ö¿Í»§¶Ë¡£»ùÓÚÕâ¸ö¼òµ¥µÄÄ£ÐÍ£¬¾Í¿ÉÒÔ½øÈëÍøÂç±à³Ì¡£
Java¶ÔÕâ¸öÄ£Ð͵ÄÖ§³ÖÓкܶàÖÖApi¡£¶øÕâÀïÎÒÖ»Ïë½éÉÜÓйØSocketµÄ±à³Ì½Ó¿Ú¡£¶ÔÓÚJava¶øÑÔÒѾ­¼ò»¯ÁËSocketµÄ±à³Ì½Ó¿Ú¡£Ê×ÏÈÎÒÃÇÀ´ÌÖÂÛÓйØÌṩ¹Ì¶¨Î»ÖõķþÎñ·½ÊÇÈçºÎ½¨Á¢µÄ¡£JavaÌṩÁËServerSocketÀ´¶ÔÆä½øÐÐÖ§³Ö¡£ÊÂʵÉϵ±Äã´´½¨¸ÃÀàµÄÒ»¸öʵÁ¦¶ÔÏó²¢Ìṩһ¸ö¶Ë¿Ú×ÊÔ´Äã¾Í½¨Á¢ÁËÒ»¸ö¹Ì¶¨Î»ÖÿÉÒÔÈÃÆäËû¼ÆËã»úÀ´·ÃÎÊÄã¡£
 
ServerSocket server=new
ServerSocket(6789);
ÕâÀïÉÔ΢ҪעÒâµÄÊǶ˿ڵķÖÅä±ØÐëÊÇΨһµÄ¡£ÒòΪ¶Ë¿ÚÊÇΪÁËΨһ±êʶÿ̨¼ÆËã»úΨһ·þÎñµÄ¡£ÁíÍâ¶Ë¿ÚºÅÊÇ´Ó0~65535Ö®¼äµÄ£¬Ç°1024¸ö¶Ë¿ÚÒѾ­±»Tcp/Ip ×÷Ϊ±£Áô¶Ë¿Ú£¬Òò´ËÄãËù·ÖÅäµÄ¶Ë¿ÚÖ»ÄÜÊÇ1024¸öÖ®ºóµÄ¡£
ºÃÁË¡£ÎÒÃÇÓÐÁ˹̶¨Î»Öá£ÏÖÔÚËùÐèÒªµÄ¾ÍÊÇÒ»¸ùÁ¬½ÓÏßÁË¡£¸ÃÁ¬½ÓÏßÓÉ¿Í»§·½Ê×ÏÈÌá³öÒªÇó¡£Òò´ËJavaͬÑùÌṩÁËÒ»¸öSocket¶ÔÏóÀ´¶ÔÆä½øÐÐÖ§³Ö¡£Ö»Òª¿Í»§·½´´½¨Ò»¸öSocketµÄʵÀý¶ÔÏó½øÐÐÖ§³Ö¾Í¿ÉÒÔÁË¡£
 
Socket client=new
Socket(InetAddress.getLocalHost()£¬5678);
¿Í»§»ú±ØÐëÖªµÀÓйطþÎñÆ÷µÄIPµØÖ·¡£¶ÔÓÚ×ÅÒ»µãJavaÒ²ÌṩÁËÒ»¸öÏà¹ØµÄÀàInetAddress ¸Ã¶ÔÏóµÄʵÀý±ØÐëͨ¹ýËüµÄ¾²Ì¬·½·¨À´Ìṩ¡£ËüµÄ¾²Ì¬·½·¨Ö÷ÒªÌṩÁ˵õ½±¾»úIP ºÍͨ¹ýÃû×Ö»òIPÖ±½ÓµÃµ½InetAddressµÄ·½·¨¡£

 
ºÃÁË£¬ÉÏÃæµÄ·½·¨»ù±¾¿ÉÒÔ½¨Á¢Ò»ÌõÁ¬ÏßÈÃÁ½Ì¨¼ÆËã»úÏ໥½»Á÷ÁË¡£¿ÉÊÇÊý¾ÝÊÇÈçºÎ´«ÊäµÄÄØ?ÊÂʵÉÏI/O²Ù×÷×ÜÊǺÍÍøÂç±à³ÌϢϢÏà¹ØµÄ¡£ÒòΪµ×²ãµÄÍøÂçÊǼÌÐøÊý¾ÝµÄ¡£³ý·ÇÔ¶³Ìµ÷Ó㬴¦ÀíÎÊÌâµÄºËÐÄÔÚÖ´ÐÐÉÏ¡£
·ñÔòÊý¾ÝµÄ½»»¥»¹ÊÇÒÀÀµÓÚIO²Ù×÷µÄ¡£ËùÒÔÄãÒ²±ØÐëµ¼ÈëJava¡£ioÕâ¸ö°ü¡£JavaµÄIO²Ù×÷Ò²²»¸´ÔÓ¡£ËüÌṩÁËÕë¶ÔÓÚ×Ö½ÚÁ÷ºÍUnicodeµÄ¶ÁÕߺÍдÕߣ¬È»ºóÒ²ÌṩÁËÒ»¸ö»º³åÓÃÓÚÊý¾ÝµÄ¶Áд¡£
 
BufferedReader


Ïà¹ØÎĵµ£º

Java²¢·¢±à³Ì ÉÏ

Ò»¡¢Ïß³Ì
1 Ï̵߳Ĵ´½¨
´´½¨Ïß³Ìͨ³£ÓÐÁ½ÖÖ·½·¨: 1) À©Õ¹ThreadÀàʵÏÖÏ̵߳Ĵ´½¨ÊÇ×î³£ÓÃÒ²ÊÇ×îÖ±½ÓµÄÒ»ÖÖ·½·¨£¬Í¨¹ý¼Ì³ÐÀàThreadʵÏÖÏß³ÌÌ壻2) ͨ¹ýʵÏÖRunnable½Ó¿ÚʵÏÖÏß³ÌÌå¡£
2 ThreadÀàµÄ¼¸ÖÖ¹¹Ô캯Êý
    1) Thread()
    2) Thread(Runnable target)
    3) T ......

ArrayParameters.java £¨j»ù p45£©

//´«µÝ²ÎÊý£¬ºÍcÖд«µØÖ·ÓеãÏñ
public class ArrayParameters {
public static void changeOrNot (int i, double[] x) {
i =-1;
x[0] = -2.0;
double[] y = x;
y[1] = -3.0;
double[] z = {4.0, 4.0, 4.0};
x = z;
}
public static void main (String[] args) {
String s1 = ......

JAVA³£ÓòÙ×÷Óï¾ä ÏîÄ¿ÖеÄ×ܽá¶þ


jspÊä³ö¸ñʽ»¯ºóµÄÈÕÆÚ
<fmt:formatDate value="${whiteNumber.crtdate }" pattern="yyyy-MM-dd HH:mm:ss"/>
ÈçÊÇmodelÀïµÄlistÔÚactionÖÐÈ¡²»µ½Öµ¡£¿ÉÄÜÔÚ¸ÃmodelÖеÄlistµÄsetterºÍgetter·½Ê½ÖУ¬Ê¹ÓõĿÉÄÜÊÇlazy¼ÓÔØ£¬¸ÄΪEAGER¼´¿É¡£
<s:iterator>±êÇ©ÀﻹÓÐ<s:iterator>± ......

java ÊÂÎñÏÝÚå

ÕâƪÎÄ×ÖдµÄºÜºÃ£¬ÍƼö¸ø×Ô¼ººÍ´ó¼Ò£¡
ÊÂÎñ²ßÂÔ: Á˽âÊÂÎñÏÝÚå
ÔÚ Java ƽ̨ÖÐʵÏÖÊÂÎñʱҪעÒâµÄ³£¼û´íÎó
 
 
 
¼¶±ð£º Öм¶
Mark Richards, Ö÷¹ÜºÍ¸ß¼¶¼¼Êõ¼Ü¹¹Ê¦, Collaborative Consulting, LLC
2009 Äê 3 ÔÂ 06 ÈÕ
ÊÂÎñ´¦ÀíµÄÄ¿±êÓ¦¸ÃÊÇʵÏÖÊý¾ÝµÄ¸ß¶ÈÍêÕûÐÔºÍÒ»ÖÂÐÔ¡£±¾ÎÄÊÇΪ Java ƽ̨¿ª· ......

javaÊý¾Ý¿âÁ¬½Ó¼°²âÊÔ(sqlserver)


package com.test.util;
import java.sql.*;
public class ConnectDB {
 private Connection conn=null;
 private PreparedStatement pt=null;
 private ResultSet rs=null;
 private String uname="sa";
 private String upwd="sa";
 private String url="jdbc:microsoft:sqlserv ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ