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

📄 serveur.java

📁 TCP Connection using java
💻 JAVA
字号:
import java.net.*;
import java.io.*;
public class serveur{
ServerSocket ss;
public serveur(int port) throws IOException
{
ss=new ServerSocket(port);
}
public void go()
{
while (true)
{
	try
	{
		Socket so = ss.accept();
		echange(so.getInputStream(), so.getOutputStream());
		so.close();
	}
	catch (IOException e)
	{ }
}
}
public void echange(InputStream is,OutputStream os) throws IOException
{
DataOutputStream dos=new DataOutputStream(os);
dos.writeUTF("Hello net Wrold!!");

DataInputStream dis = new DataInputStream(is);
String tmp = dis.readUTF();
System.out.println(tmp);
}
public static void main(String argc[])
{
	try{
		
serveur s = new serveur(3000);
s.go();
	}
	catch(IOException e){}
}
}

⌨️ 快捷键说明

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