자바 9 절 네트워크 프로 그래 밍 의 기초 지식

10888 단어 자바
/**
 * 
 *          
 *          TCP/IP
 *     IP   Port(   )
 *               IP  :127.0.0.1
 *                 0-65535  ,0-1023                        
 *     UDP TCP
 *          TCP,      (Transmission Control Protocol),          
 *          UDP,       (User Datagram Protocol),        
 *
 *          TCP UDP          
 *                 IP   IP                 
 *                                                 TCP, UDP
 *
 *    Socket
 *       Socket                       
 *          Socket          ,               ,          
 *                       ,     
 *       
 *       Socket        ,                 ,       IP Port
 * 
 *       Socket      
 *            1   Socket->    
 *            2     (  bind Socket          )->    
 *            3     (                         ,             Socket )->Socket
 *            4 Socket(     Socket    ) ->     
 *
 *
 *       Java       
 *              java.net  
 *            DatagramSocket   UDP  
 *            ServerSocket   TCP       
 *            Socket   TCP          
 *
 *
 *   UDP    
 *      DatagramSocket 
 *             
 *             public DatagramSocket()
 *             public DatagramSocket(int port)
 *             public DatagramSocket(int port, InetAddress laddr)
 *         close  
 *         send(DatagramPacket p)  
 *         receive(DatagramPacket p)  
 *
 *      DatagramPacket 
 *            DatagramSocket         ,  DatagramPacket             ,
 *             :
 *             public DatagramPacket(byte[] buf, int length)
 *             public DatagramPacket(byte[] buf, int length, InetAddress address, int prot)
 *         getInetAddress getPort  
 *         getData getLength  
 *
 *      InetAddress 
 *         InetAddress        IP      ,               ""
 *         
 *          UDP  
 *                        
 *         UDP           ,    UDP         ,
 *          start              
 *                     
 *
 * 
 *       UDP        
 *         1                  
 *         2             IP  
 *         3                   ,      
 *                  :
 *            1         
 *            2           
 *            3           
 *             :
 *            1                   ?
 *            2         ?
 *            3        Interent    ?    IP              ?
 *
 *           IP           
 * 
 *
 * TCP    
 *     TCP         
 *          ClientlSocket ->         ServerSocket
 *                      Socket ->  client  Socket 
 *            Socket        
 *          
 *          TCP      TCP           :
 *             1          ServerSocket,    accept         
 *             2          Socket           
 *             3             ,       Socket          
 *             4         Socket        (        )   
 *             5             ,          ,    (2)   (5)   
 * 
 *
 *     ServerSocket 
 *               :
 *              public ServerSocket();
 *              public ServerSocket(int port)
 *              public ServerSocket(int port, int backlog)
 *              public ServerSocket(int port, int backlog, InetAddress bindAddr)
 *           close()  
 *           accept  
 *
 *
 *     Socket 
 *             :
 *             public Socket();
 *             public Socket(String host, int port)
 *             public Socket(InetAddress address, int port)
 *             public Socket(String host, int port, InetAddress localAddr, int localPort)
 *             public Socket(InetAddress address, int port, InetAddress localAddr, int localPort)
 *         getInputStream getOutputStream  
 *
 *         
 *        TCP     
 *         TCP           ,TCP        TCP   
 *           Windows   telnet    TCP     
 *           BufferedReader   ,               
 *             telnet         
 *
 *
 *
 *        TCP       
 *            :
 *                            ,                 ,                            ,                    "quit" ,
 *                       
 *
 *        TCP            :
 *           TCP                 ,      ServerSocket.accept  
 *                                   ,           
 *                          Socket      ,              
 *
 *     
 *                  
 *            netstat            TCP   
 *                     TCP           
 *
 *
 *     TCP     
 *             :
 *                                  
 *           :
 *                   IP                  ,               ,               
 *
 *
 *
 *       TCP           
 *         ObjectInputStream ObjectOutputStream                                   
 *         
 *           ObjectInputStream ObjectOutputStream          ,TCP    TCP                 
 *         
 *             :      Java  
 *
 *                                       
 *                      ASP, JSP        
 *
 *   Internet    
 *    java.net    URL, URLDeconder, URLEncoder, URLConnection, HttpURLConnection  
 *
 *           
 *        URL(       )
 *        HTTP  
 *        URL 
 *              
 *        URLConnection HttpURLConnection 
 * 
 *    URL(Uniform Resource Locator)
 *       URL     :  ,   ,   ,   
 *         :http://www.ituji.cn:8080/index.html
 *
 *         URL,  "/a.html" "./a.html" "../../a.html" "a.html"
 *
 *       URL    
 *                  (+)
 *           0-9 a-z A-Z         
 *                   ,                          ,
 *                        (%),   "+" %2B  ,  "=" %3D  ,  "&" %26  ,              ,  “ ” %D6%D0  ,  " " %B9%FA  
 *                              ,  %20  ,          (+).
 *       java.net     URLEncoder URLDecoder    ,   URL     
 *
 *
 *   HTTP                
 *          HTTP1.0                  
 *            ->      ->      ->    
 *
 *          HTTP1.1                
 *            ->       ->   N   ->        ->    
 *
 *    HTTP    
 *                   :     ,     ,      .
 *          :
 *           GET /articles/news/today.aps HTTP/1.1
 *           Accept:*
 *           Accept-Language:en-us
 *           Connection: Keep-Alive
 *           Host:location
 *           Referer: http://localhost/links.aps
 *           User-Agent: Mozilla/4.0(compatible; MSIE 5.5; Windows NT5.0)
 *           Accept-Encoding:gzip, deflate
 *	         
 *      HTTP    
 *                     :     ,     ,      
 *            :
 *            HTTP/1.1 200 OK
 *            Server: Microsoft-IIS/5.0 
 *            Date: Thu, 13 Jul 2000 05:46:53 GMT
 *            Content-Length: 2291
 *            Content-Type:text/html
 *            Set-Cookie: XXXXX; path=/;
 *            Cache-control:private
 *
 *        <HTML>
 *        ................
 *        </HTML>
 *
 *            HTTP   
 *          Connection 
 *                          /   ,               ,      Keep-Alive close
 *          Accept-Language
 *                                        ,                
 *          Content-Length
 *                          (   )
 *          Range 
 *                                        ,         
 *               1): Range: bytes=100-599       100 599 
 *               2): Range: bytes=100-         100    
 *               3): Range: bytes=-100           100  
 *          Content-Range:
 *                                    ,  :
 *               Content-Range: bytes 2543-4532/7898
 *
 *   URL 
 *          (    MalformedURLException  )
 *          public URL(String spec)
 *          public URL(String protocol, String host, int port, String file)
 *          public URL(String protocol, String host, int prot, String file, URLStreamHandler handler)
 *          public URL(URL context, String spec) 
 *
 *     getProtocol, getHost, getPort, getFile   
 *       
 *     openConnection    URLConnection  
 * 
 *           
 *         URL  setURLStreamHandlerFactory(URL StreamHandlerFactory fac)    
 *
 *         StreamHandlerFactory  createURLStreamHandler(String protocol)  
 *
 *
 *  URLConnection HttpURLConnection 
 *      URLConnection HttpURLConnection   
 *      URLConnection     
 *      setRequestProperty  
 *      getHeadFields  
 *      getInputStream getOutputStream  
 *      getHeaderFiled, getContentLength, getContentEncoding, getContentType   
 *        HTTP       HttpURLConnection      ,  HttpURLConnection disconnect            
 *
 *          :   www.google.com   HTTP     Accept-Language            ,     www.google.com                 
 *
 *
 *      (1)
 *      1   TCP, UDP     ,   TCP UDP   
 *      2         , Socket,                     
 *      3      UDP      
 *      4     TCP             Servicer            :
 *            pw.println(strWord+"--->"+strEcho);
 *                        
 *        pw.print(strWord+"--->"+strEcho+"\r
"); * pw.print(strWord+"--->"+strEcho+System.getProperty("line.separator")); * , ? * 5 TCP , , , * , * 6 HTTP , web * 7 HTTP Range Content-Range ,URL HttpURLConnection , HTTP * * * * @(#)lesson9.java * * lesson9 application * * @author * @version 1.00 2013/9/1 */ public class lesson9 { public static void main(String[] args) { // TODO, add your application code System.out.println("Hello World!"); } }

좋은 웹페이지 즐겨찾기