⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sclient.java

📁 远程文件传输
💻 JAVA
字号:
import java.io.*; 
import java.net.*; 

public class SClient 
{ 
 public static void main(String[] args) 
{ 

 String s=null;
 Socket mysocket;
 DataInputStream    in=null;
 DataOutputStream   out=null;

try 
{ 
mysocket = new Socket("localhost",4321); 
in = new DataInputStream(mysocket.getInputStream()); 
out = new DataOutputStream(mysocket.getOutputStream());  
out.writeUTF("我是客户机,向你请求连接。"); 
while (true)
 {
 	s=in.readUTF();
    if(s!=null) break;
 }
mysocket.close();
}
catch(IOException e){System.out.println("无法连接");}
System.out.println(s);
}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -