android - exception while trying to receive a file from server -
I run some code to connect to a server, send it to an object and then get an object while my Android This is going on in the Anululator (v2.2) - This is my connector class: And I use this code to run: Any ideas? shutting the object overtput () to send () to wind the built-in socket So when you get InputStream () the reciveResponseFromServer () socket is already closed? java.net.SocketException: The socket is off The connection to the server is successful and I am able to send the object, but when I have the
socket Trying to getInputStream () this throws an exception
Wajnik class Knekshncosrsevr {UserProblemRequest sentProblem; Problem response problem; Socket socket; Public connectionToSure () {sent problem = zero; Reaction effect = zero; Socket = null; } Public Zero Connect () {try.d (tag, "connecting ..."); Socket = new socket (UTILS SRNNIP, UTILSERERRR) log D. (Tag, "success: connected!"); } Hold (unknownhostexception e) {log d. (Tag, "Error: file to connect! (UnknownHype extension)"); E.printStackTrace (); } Hold (IOException e) {log d. (Tag, "Error: file to connect! (IOException)"); E.printStackTrace (); }} Public Zero Set PrognosisBetaarerere (Byte [] Data, Boolean Isilfile) {Sent Problem = New User Problem (Request); SentProblem.fileBArray = data.clone (); If (isFile) {sentProblem.requestType = Utils.requestType_IMAGE; } Other {sent problem Request type = uTill Request Type_STRING; }} The problem of sending a public null () {object overputstream OS; Try {Os = new object altitude (socket.getOutputStream ()); Log D. (Tag, "sending file to server ..."); Os.writeObject (sentProblem); Os.flush (); Os.close (); } Hold (IOException e) {log d. (Tag, "Error: file to send file to server!"); E.printStackTrace (); } Log D. (Tag, "success: file has been sent to server!"); } Public Zero-Lock Connection () {try {socket.close ()}} Grip (IOException e) {Log D. (The tag "failed to close the socket"); E.printStackTrace (); }} Public problem reciveResponseFromServer () {ObjectInputStream ois; {Ois = new ObjectInputStream (socket.getInputStream ()); Reaction effect = (problem) ois.readObject (); } Hold (Streamcorporated Expression E) {e.printStackTrace (); } Hold (IOException e) {e.printStackTrace (); } Grip (Klassnotfound Expression E) {e.printStackTrace (); } Return response problem; }}
Connection server server connection = new connectionTosser (); ServerConnection.connect (); ServerConnection.setProblemFromByteArray (temp_data, true); ServerConnection.sendProblem (); Problem response problem = serverConnection.reciveResponseFromServer (); ServerConnection.closeConnection ();
Comments
Post a Comment