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

Source: Internet
Author: User

 Packagecn.rwkj.test;Importjava.io.IOException;ImportJava.io.InputStream;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); } 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; }        Public string getString (InputStream in) throws ioexception{string str= "";    byte [] b=new byte[1024];    int len=-1;        while (len = In.read (b))!=-1) {System.out.println (len);        str = new String (b);    Break } return str; }}

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

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.