2014--9=17 soft Second Class MyEclipse blue==4

Source: Internet
Author: User

 Packagecn.rwkj.test;Importjava.io.IOException;ImportJava.io.InputStream;ImportJava.io.OutputStream;ImportJava.io.PrintWriter;ImportJava.net.ServerSocket;ImportJava.net.Socket; Public classTestsocket {PrivateSocket sock=NULL ; Private StaticServerSocket Server =NULL; Private Static intport=8080 ;  PublicTestsocket () {//Define a method                Try{System.out.println (A); Server=NewServerSocket (port);                        Server.accept (); System.out.println ("IP:" +sock.getinetaddress ()); InputStream in=Sock.getinputstream (); String Str=getString (in);                                                System.out.println (str); OutputStream  out= Sock.getoutputstream (); PrintWriter Write                         =new PrintWriter (out);            Write.println ("http/1.0.200 OK"); Write.println ("content-type:/html;                        CHARSET:GBK ");            Write.println (); Write.println ("Asdfasdf");                                            Write.close (); } Catch(IOException e) {//TODO auto-generated Catch blockE.printstacktrace (); }                    }         Public Static voidMain (String []args) {NewTestsocket (); }             PublicSocket Getsock () {returnsock; }     Public voidSetsock (Socket sock) { This. Sock =sock; }     PublicServerSocket getserver () {returnserver; }     Public voidsetserver (serversocket server) { This. Server =server; }         PublicString getString (InputStream in)throwsioexception{String str=""; byte[] b=New byte[1024]; intLen=-1;  while(len = In.read (b))!=-1) {System.out.println (len); STR=NewString (b);  Break; }    returnstr; }}

2014--9=17 soft Second Class MyEclipse blue==4

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.