java UDPģʽͨѶʵÀý javaѧϰ±Ê¼Ç(5)
Ò»°ãʹÓÃsocket½¨Á¢µÄÁ¬½Ó¶¼ÊôÓÚTCPÁ¬½ÓµÄģʽ..¾ÍÊÇÒ»°ãҪͨ¹ýÈý´ÎÎÕÊÖÀ´½¨Á¢session..È»ºóÔÙ´«ËÍÊý¾Ý..
¶øUDPģʽ²»Í¬µÄµØ·½ÔÚÓÚ..Ëü²»ÐèÒª½¨Á¢ºÍËûÈ˵ÄÁ¬½Ó..¶øÊÇÖ±½ÓÍùһ̨Ö÷»úµÄijһ¸ö¶Ë¿ÚÉÏ·¢ËÍÊý¾Ý±¨ÎÄ..
¶ÔÓÚһЩ¶ÔͨÐÅÖÊÁ¿ÒªÇ󲻸߻òÕß˵Êý¾ÝÏ¡ÊèµÄͨÐÅÀ´Ëµ..ÓÃUDPģʽÊÇÒ»¸ö²»´íµÄÑ¡Ôñ..
ÏÂÃæÊÇÒ»¸öÓÃjavaʵÏÖµÄÁÄÌìͨѶµÄ³ÌÐòʵÀý:
·¢ËͶ˴úÂë..ÓÃÀ´ÏìÓ¦Óû§µÄÊäÈë²¢½«ÄÚÈÝ·¢Ë͸ø¶Ô·½..
class UDPSendThread extends Thread {//ÓÉÏß³ÌÀ´ÊµÏÖ
public DatagramPacket dp = null;//Êý¾Ý±¨°ü..
public DatagramSocket ds = null; //Êý¾Ý±¨°üµÄÌ×½Ó×Ö..
UDPSendThread(DatagramPacket dp, DatagramSocket ds) {
this.dp = dp;
this.ds = ds;
this.start();
}
@Override
public void run() {
try {
BufferedReader keyIn = new BufferedReader(new InputStreamReader(System.in));//Óû§ÊäÈëÊý¾Ý
String s;
while (true) {
s = keyIn.readLine();//×èÈû³ÌÐò..Ö±µ½Óû§ÊäÈëÐÅÏ¢
dp.setData(s.getBytes());//ÓÃÓû§ÊäÈëµÄÐÅÏ¢À´ÉèÖÃÊý¾Ý±¨°ü
System.out.println("You: "+s);
ds.send(dp);//ÓÃÊý¾Ý±¨°üµÄÌ×½Ó×ÖÀ´·¢ËÍÊý¾Ý±¨°ü..
if ( s.trim().equals("BYE") ) break;//Èç¹ûÓû§ÊäÈëÐÅϢΪ"BYE"Ôò½áÊøͨÐÅ..
}
keyIn.close();
ds.close();
}
catch(Exception e) {
System.out.println("Error: Send: "+e);
}
}
}
½ÓÊն˴úÂë..ÓÃÀ´¼àÌý¶Ë¿Ú..½«ÊÕµ½µÄÐÅÏ¢ÏÔ³ö³öÀ´..
class UDPRecvThread extends Thread {//Ïß³ÌʵÏÖ
public DatagramPacket dp = null;//Êý¾Ý±¨°ü
public DatagramSocket ds = null; //Êý¾Ý±¨°üµÄÌ×½Ó×Ö
UDPRecvThread(DatagramPacket dp, DatagramSocket ds) {
this.dp = dp;
this.ds = ds;
this.start();
}
@Override
public void run() {
try {
Ïà¹ØÎĵµ£º
BODY { color: #000000; font-size: 9pt; font-family: ËÎÌå }
TABLE { font-size: 9pt; font-family: ËÎÌå }
SimpleDateFormat sdfy = new SimpleDateFormat("HH:mm");
String tt =
"Tue Feb 09 10:43:00 CST 2010";
&n ......
package test;
public class TestFactory<T> {
private Class <T> cls;
public String testabc="";
pub ......
7.3 µã»÷ElementºÍÌîд±íµ¥
ÎÒÃÇ¿ÉÒÔ°²È«µÄ¼ÓÔØÒ³Ã棬³éÈ¡ÐÅÏ¢£¬µ«ÊÇÓÐʱä¯ÀÀÍøÒ³ÊÇÐèÒªÌîд±íµ¥²¢Ìá½»»òÕßµã»÷ij¸öÔªËØÀ´´¥·¢onclickÒÔ±ãÖ´ÐÐÒ»¶Î
JavaScript´úÂë¡£
àÅ£¬ÒªÏëµã»÷Ò»¸öelementÐèÒª»ñµÃÕâ¸öelement(Ç°ÃæµÄxpathNodesÒ²Ðí¿ÉÒÔ°ïÎÒÃÇ×öµ½Õâµã)£¬Èç¹ûÊÇinput element£ ......
BorderLayout
FlowLayout
GridLayout
GridBagLayout
CardLayout
BoxLayout
< type="text/javascript">
document.body.oncopy = function() {
if (window.clipboardData) {
......