2013年9月23日星期一

Novice inquired java network programming problem seeking Moderators do not delete

These are the server program
above is a client program
above is displayed when the first input interface
problem here , and the second input of the client actually wanted to report this error , the Internet seems to be said that the port issue , seeking to give a detailed explanation of the great God < br> ------ Solution ----------------------------------------- ---
service side of the socket each receive complete , finally there will socket.close (), of course, being given ;

suggest you put socket = socketServer.accept (); advance to the while (true) front ;
------ Solution -------------- ------------------------------
your client socket stream is closed , that is, they are a bridge of communication by you to cut off , so you can not communicate .
------ Solution ---------------------------------------- ----


indeed this reason, you should determine the end of the service , to determine if the client is disconnected , the server also put this link is disconnected .
------ Solution ---------------------------------------- ----
client , the while (true) put try inside, so customers that have been circulating when socket is opened .
Also, do not recommend using while (true) form , you can define a variable boolean b = true; Then while (b) form , if you want to break the loop , only need to add b setter methods , stresses the value is set to false.
end of the loop is executed in the method finally closed socket.
proposal sent to the client before the closure of an identifier , which means that close , easy to service -side processing .
------ For reference only -------------------------------------- -
Thank you Daniel, probably figure out what 's going on up

没有评论:

发表评论