Frage

  1. Does a file-class only keeps the link/path to a file or a copy of that in the memory ? I ask that in case of transfering a "File" object through network - is the path of the file transfered or the file too ?

  2. Client-server communication (for a simple network game)

Story: i will have several clients wich are frequently need a information or file transfer with a Server in unknown order and number. The server also should send in a unknown order informations/files to the clients. The server treated connections in making threads wich handle them.

Questions: What is the recommended approach to handle those situations?

I dont know if it is better to close the connection and thread every time the informations/file transfere is over and open a new one or to hold a thread and the socket connection for more.

  1. Linked with the question above - does the client use threads for incoming information/file transfers of the server too?

  2. Is there a recommended way how i identify and store/handle the client connections, lost connections , reconnections.

I would be pleased if you could give me some hints.

Best wishes Mathias

War es hilfreich?

Lösung

In Java, File is just an abstraction to a file system path (file or directory); it does not contain the file contents.

In a client/server set up where you need to send a file over the network, you will need to use Java's IO constructs for that. Exactly how will depend on how you intend communication to be done (HTTP, Sockets, RMI).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top