1.socketjavaԴ?源码?
2.用Java Socket编程,实现简单的源码育儿工具源码Echo功能
socketjavaԴ??
//客户端
public static void main(String[] args) throws Exception
{
Socket socket = new Socket(".0.0.1", );
OutputStream os = socket.getOutputStream();
os.write("hello world".getBytes());
os.close();//客户端使用完流之后记得要关闭!!源码2022聊天源码
}
//服务端
public static void main(String[] args) throws Exception
{
ServerSocket ss = new ServerSocket();
Socket socket = ss.accept();
InputStream is = socket.getInputStream();
byte[] buffer = new byte[];
int length = 0;
while (-1 != (length = is.read(buffer,源码获利比例90%源码 0, buffer.length)))//这句错了,是源码unity源码怎么换皮不等于!
{
String str = new String(buffer,源码网址大全SEO源码 0, length);
System.out.println("welcome "+str);
}
}
用Java Socket编程,实现简单的源码Echo功能
// 服务器
import java.io.*;
import java.net.*;
public class MyServer {
public static void main(String[] args) throws IOException{
ServerSocket server=new ServerSocket();
while (true) {
Socket client=server.accept();
BufferedReader in=new BufferedReader(new InputStreamReader(client.getInputStream()));
PrintWriter out=new PrintWriter(client.getOutputStream());
while(true){
String str=in.readLine();
System.out.println(str);
out.println("has receive....");
out.flush();
if(str.equals("exit"))
break;
}
client.close();
}
}
}
// 客户端
import java.net.*;
import java.io.*;
public class Client{
static Socket server;
public static void main(String[] args)throws Exception{
server=new Socket(InetAddress.getLocalHost(),);
BufferedReader in=new BufferedReader(new InputStreamReader(server.getInputStream()));
PrintWriter out=new PrintWriter(server.getOutputStream());
BufferedReader wt=new BufferedReader(new InputStreamReader(System.in));
while(true){
String str=wt.readLine();
out.println(str);
out.flush();
if(str.equals("end")){
break;
}
System.out.println(in.readLine());
}
server.close();
}
}
2024-11-26 20:362679人浏览
2024-11-26 20:071346人浏览
2024-11-26 19:53351人浏览
2024-11-26 19:44147人浏览
2024-11-26 19:361807人浏览
2024-11-26 19:181285人浏览
1.��������Դ��2.求JSP网站模版?3.php修仙文字游戏源码如何下载4.å°ç¨åºä½ä»£ç å¼åå¹³å°ï¼5.擒龙突破捉妖之龙腾四海主图/选股指标公式源码
1.搜索引擎营销是什么个概念?对企业业绩增长有作用么?2.cpschecke好不好3.怎样推广自己的网店?4.cps如何设置搜索引擎营销是什么个概念?对企业业绩增长有作用么? 搜索引擎营销,是英文
1.分享一个综合性又实用的游戏素材网站2.站长窝_仿熊猫办公素材站PPT模板下载站整站源码+WAP手机端+采集器+整站数据门户3.素材中国简介4.有哪些免费设计素材网站分享一个综合性又实用的游戏素材网