Java??socket????UDPЭ??
???????????? ???????[ 2016/1/4 11:04:47 ] ??????????????????? ???????
???????2
??????????
package com.socket.demo;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
public class UDPReceiveDemo2 {
public static void main(String[] args) throws IOException{
System.out.println("????????…………");
/*
2??????UDP??socket????????????????????
3????????????????????????????????????????????????????????Щ????
4?????DatagramSocket??receive?????????????????洢?????????
5?????????????????????????е?????
5?????socket????
*/
//udpsocket???????DatagramSocket????
DatagramSocket ds=new DatagramSocket(10003);
while(true){
//???DatagramPacket?????????????????
byte[] buf=new byte[1024];
DatagramPacket dp=new DatagramPacket(buf?? buf.length);
//???udp??socket????????????????????send????
ds.receive(dp);//????????
//???????????????????????е?????????????????????????????
String ip=dp.getAddress().getHostAddress();
//String name=dp.getAddress().getHostName();
int port=dp.getPort();
String text=new String(dp.getData()??0??dp.getLength());
//System.out.println("-----"+ip+"-----"+name+"-----"+port+"-----"+text);
System.out.println("-----"+ip+"----------"+port+"-----"+text);
}
//??????
//ds.close();
}
}
??????????
package com.socket.demo;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
public class UDPSendDemo2 {
public static void main(String[] args) throws IOException{
System.out.println("????????…………");
/*
* 1??????udp?????????
2??????UDP??socket?????
3?????????????????????????
4?????udp??socket???????????????
5?????socket????
*/
//udpsocket???????DatagramSocket????
DatagramSocket ds=new DatagramSocket(9999);//???????
//???????????????????????
//String str="udp?????????go";
BufferedReader bufr=new BufferedReader(new InputStreamReader(System.in));//????????
String line=null;
//???DatagramPacket?????????????????
while((line=bufr.readLine())!=null){
byte[] buf=line.getBytes();//
DatagramPacket dp=
new DatagramPacket(buf?? buf.length??InetAddress.getByName("192.168.1.100")??10003);
//???udp??socket????????????????????send????
ds.send(dp);
if("886".equals(line)){
break;
}
}
//??????
ds.close();
}
}
???????Ч?????
????????
????????
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
Java???????????Щ???????????????Java????????????????Java?б???Map????????Java Web???????????????Java??????????????д?????Java????????7???????????????????????(java .net ?????)???Java??????????Python??????Java webdriver??λ????????′????е?????Java??д??????????????????Java???????????????JavaScript????????????Java?????????????????? Java???????10??????????????Java?м????????????????java???????ü???????????м???????????????????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????