第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Connection reset錯(cuò)誤

Connection reset錯(cuò)誤

隨便一個(gè)名 2016-12-18 12:12:37
客戶端 import?java.io.BufferedReader; import?java.io.IOException; import?java.io.InputStream; import?java.io.InputStreamReader; import?java.io.OutputStream; import?java.io.PrintWriter; import?java.net.Socket; import?java.net.UnknownHostException; public?class?Client?{ public?static?void?main(String[]?args)?{ try?{ //?創(chuàng)建客服端Scoket,指定服務(wù)器地址和端口 Socket?socket?=?new?Socket("192.168.1.67",?8787);//?localhost表示本地地址 //?獲取輸出流,想服務(wù)器端發(fā)送信息 OutputStream?outputStream?=?socket.getOutputStream();//?字節(jié)流輸出 PrintWriter?printWriter?=?new?PrintWriter(outputStream);//?將字節(jié)流轉(zhuǎn)換成(包裝為)打印流 printWriter.write("用戶名:admin\t密碼:123123"); printWriter.flush();//?調(diào)用flush()刷新緩存 socket.shutdownInput();//?關(guān)閉輸出流 //獲取輸入流,并讀取服務(wù)器端的響應(yīng)信息 InputStream?inputStream=socket.getInputStream(); InputStreamReader?inputStreamReader=new?InputStreamReader(inputStream); BufferedReader?bufferedReader=new?BufferedReader(inputStreamReader); String?data=bufferedReader.readLine(); if?(data!=null)?{ System.out.println("我是客服端:服務(wù)器說(shuō)"+data); } //?關(guān)閉資源 inputStreamReader.close(); bufferedReader.close(); inputStream.close(); outputStream.close(); printWriter.close(); }?catch?(UnknownHostException?e)?{ e.printStackTrace(); }?catch?(IOException?e)?{ e.printStackTrace(); } } } 服務(wù)器 import?java.io.BufferedReader; import?java.io.IOException; import?java.io.InputStream; import?java.io.InputStreamReader; import?java.io.OutputStream; import?java.io.PrintWriter; import?java.net.ServerSocket; import?java.net.Socket; public?class?Server?{ public?static?void?main(String[]?args)?{ try?{ //?創(chuàng)建一個(gè)服務(wù)器端的Socket,即ServerSocket。指定綁定端口,并監(jiān)聽(tīng) ServerSocket?serverSocket?=?new?ServerSocket(8787); System.out.println("*********服務(wù)器即將啟動(dòng),等待客戶端連接********"); //?調(diào)用accept()開(kāi)始監(jiān)聽(tīng),等待客戶端連接。 Socket?socket?=?serverSocket.accept(); //?獲取輸入流,并讀取客戶端信息。 InputStream?inputStream?=?socket.getInputStream();//?字節(jié)流輸入 InputStreamReader?inputStreamReader?=?new?InputStreamReader(inputStream);//?將字節(jié)流轉(zhuǎn)化為字符流 BufferedReader?bufferedReader?=?new?BufferedReader(inputStreamReader);//?為輸入流添加緩沖 String?data?=?null; while?((data?=?bufferedReader.readLine())?!=?null)?{ System.out.println("我是服務(wù)器:客服端說(shuō):"?+?data); //?data?=?bufferedReader.readLine(); }?//?循環(huán)讀出客戶端的信息 //?獲取輸出流,響應(yīng)客戶端請(qǐng)求 OutputStream?outputStream?=?socket.getOutputStream(); PrintWriter?printWriter?=?new?PrintWriter(outputStream);//?包裝為打印流 printWriter.write("歡迎您"); printWriter.flush();//?調(diào)用flush()將緩存輸出 //?關(guān)閉相關(guān)的資源 socket.shutdownInput();//?關(guān)閉輸入流 printWriter.close(); outputStream.close(); inputStream.close(); inputStreamReader.close(); bufferedReader.close(); }?catch?(IOException?e)?{ //?TODO?Auto-generated?catch?block e.printStackTrace(); } } } 錯(cuò)誤 *********服務(wù)器即將啟動(dòng),等待客戶端連接******** java.net.SocketException:?Connection?reset at?java.net.SocketInputStream.read(Unknown?Source) at?java.net.SocketInputStream.read(Unknown?Source) at?sun.nio.cs.StreamDecoder.readBytes(Unknown?Source) at?sun.nio.cs.StreamDecoder.implRead(Unknown?Source) at?sun.nio.cs.StreamDecoder.read(Unknown?Source) at?java.io.InputStreamReader.read(Unknown?Source) at?java.io.BufferedReader.fill(Unknown?Source) at?java.io.BufferedReader.readLine(Unknown?Source) at?java.io.BufferedReader.readLine(Unknown?Source) at?Server.main(Server.java:24)
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 3725 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)