真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

java網(wǎng)絡(luò)編程-多人登錄面向?qū)ο?/h1>

TCP:模擬登錄 :多個客戶端,先后等待

創(chuàng)新互聯(lián)于2013年成立,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目成都網(wǎng)站制作、成都做網(wǎng)站網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元雅安做網(wǎng)站,已為上家服務(wù),為雅安各地企業(yè)和個人服務(wù),聯(lián)系電話:028-86922220

public class tcp {

public static void main(String[]args) throws IOException
{
    System.out.println("

客戶端: 存儲文件

public class tcp2 {

public static void main(String[]args) throws IOException
{
    System.out.println("客戶端啟動中...");

    Socket client=new Socket("localhost",8888);

    //發(fā)送
    new send(client).sendto();
    new receive(client).receiveto();

    client.close();

}
static class send{
    private Socket client;
    private DataOutputStream dos;
    private BufferedReader br;
    private String msg;
    public send(Socket client)
    {
        this.client=client;
        br=new BufferedReader(new InputStreamReader(System.in));
        msg=init();
        try {
            dos =new DataOutputStream(client.getOutputStream());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public void sendto()
    {
        try {
            dos.writeUTF(msg);
            dos.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public String init()
    {

        try {
            System.out.println("請輸入用戶名");
            String name=br.readLine();
            System.out.println("請輸入密碼");
            String password=br.readLine();
            return name+"&"+password;
        } catch (IOException e) {

            e.printStackTrace();
        }
        return null;
    }
}

static class receive{
    private DataInputStream dis;
    private Socket client;
    public receive(Socket client)
    {
        this.client=client;
        DataInputStream dis=new DataInputStream(client.getInputStream());
    }

    public void receiveto()
    {
        String data;
        try {
            data = dis.readUTF();
            System.out.println(data);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
}

分享標題:java網(wǎng)絡(luò)編程-多人登錄面向?qū)ο?
文章URL:
http://weahome.cn/article/pdsoid.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部