Signed-off-by: markma <750975972@qq.com>
master
markma 3 years ago
commit 90b88a214f

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

1
.gitignore vendored

@ -0,0 +1 @@
/bin/

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Markma-Server</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

@ -0,0 +1,12 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8

@ -0,0 +1,7 @@
该程序是简易服务器。
有关该项目资料的查询https://www.wolai.com/81653LDk4k71WzqBnokQ5r?theme=light
我的其他项目资料https://www.wolai.com/k3a8LkCjN8xnEKTvKYPqum?theme=light
https://www.wolai.com/tqqpCNJ3U7jUHCPx13Qorx?theme=light

@ -0,0 +1,32 @@
package server;
import java.net.*;
import java.io.*;
public class Server
{
public static void main(String[] args) throws Exception
{
while(true)
{ //一直运行
ServerSocket server = new ServerSocket(8080); //监听在8080端口
Socket sock = server.accept(); //建立一个与客户机的socket
FileInputStream in = new FileInputStream("d:\\a.html"); //读取数据
OutputStream out = sock.getOutputStream();
out.write("HTTP/1.1 200 OK\r\n".getBytes());
out.write("Content-Type:text/html;charset=utf-8\r\n".getBytes());
out.write("\r\n".getBytes());//写入响应头
int len = 0;
byte buffer[] = new byte[1024]; //缓冲区
while((len=in.read(buffer))>0)
{ //假如缓冲区有数据
out.write(buffer,0,len);
}
in.close();
out.close();
sock.close();
server.close();
}
}
}
Loading…
Cancel
Save