网络监控

  ServerSocket socketServer;
        try
        {
            socketServer = new ServerSocket(10086);
            Socket client = socketServer.accept();
            InputStream inClient = client.getInputStream();
            Scanner inScn = new Scanner(inClient);
            while (inScn.hasNextLine())
            {
                System.out.println(inScn.nextLine());
            }
            inScn.close();
            client.close();
            socketServer.close();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }

对相应的IP端口进行监控,下面是打印出来的结果
GET / HTTP/1.1
Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Accept-Language: zh-cn
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727)
Accept-Encoding: gzip, deflate
Host: localhost:10086
Connection: Keep-Alive

你可能感兴趣的:(windows,.net,socket,Excel,Flash)