最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
serversocket 堵塞
时间:2008-04-28 编辑:简简单单 来源:一聚教程网
救命 救命
服务器端
package web;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
/**
*
* @author Administrator
*/
public class TcpServer {
/** Creates a new instance of TcpServer */
public TcpServer() {
}
public static void main(String[] args){
ServerSocket svesoc=null;
Socket soc=null;
InputStream is=null;
OutputStream os=null;
DataInputStream in=null;
PrintStream out=null;
try {
svesoc=new ServerSocket(8000,3);
svesoc.setSoTimeout(2000000);
soc=svesoc.accept();
is=soc.getInputStream();
os=soc.getOutputStream();
out=new PrintStream(os);
InetAddress clientIP=soc.getInetAddress();
System.out.println("Client''s IP address "+clientIP);
System.out.println("Client''s port "+soc.getPort());
out.println("welcome");
byte[] bmsg=new byte[1024];
-
上一个: J2EE学习笔记--MVC框架
相关文章
- SpringBoot测试配置属性与web启动环境解析 10-24
- vue中将el-switch值true、false改为number类型的1和0解析 10-24
- Vue中的路由配置项meta使用解读 10-24
- SpringBoot自定义bean绑定解析 10-24
- SpringBoot常用计量与bean属性校验和进制数据转换规则解析 10-24
- 工厂方法在Spring框架中的运用介绍 10-24