Download data/CopasiCS/Java/Client/ClientSocketWriter.java from introvoyz045/COPASI: direct link, hf CLI and curl.
- Browser
- Download file 1.36 kB
-
https://huggingface.co/datasets/introvoyz045/COPASI/resolve/main/data/CopasiCS/Java/Client/ClientSocketWriter.java
- Command line
-
hf download hf://datasets/introvoyz045/COPASI/data/CopasiCS/Java/Client/ClientSocketWriter.java
-
curl -L -o ClientSocketWriter.java https://huggingface.co/datasets/introvoyz045/COPASI/resolve/main/data/CopasiCS/Java/Client/ClientSocketWriter.java
1.36 kB
| package Client; | |
| /* | |
| * ClientSocketWriter.java | |
| */ | |
| import java.io.*; | |
| import java.net.*; | |
| import Common.*; | |
| /**Writes messages to be sent to the server on the socket. | |
| */ | |
| public class ClientSocketWriter | |
| { | |
| /**The ClientNetwork whose writer this component is.*/ | |
| ClientNetwork clientNetwork; | |
| //ObjectOutputStream output; | |
| DataOutputStream output; | |
| /**The constructor | |
| * @param cn The ClientNetwork whose reader this thread is. | |
| */ | |
| public ClientSocketWriter(ClientNetwork cn) | |
| { | |
| try | |
| { | |
| clientNetwork = cn; | |
| //output = new ObjectOutputStream(clientNetwork.socket.getOutputStream()); | |
| output = new DataOutputStream(clientNetwork.socket.getOutputStream()); | |
| showMessage("Got Outstream..." + output.toString()); | |
| } | |
| catch (IOException e) | |
| { | |
| showMessage("An input or output exception occured while creating ObjectOutputStream"); | |
| } | |
| } | |
| public void writeMessageToServer(Message msg) | |
| { | |
| try | |
| { | |
| //output.writeObject(msg); | |
| msg.writeDataObject(output); | |
| } | |
| catch(IOException e) | |
| { | |
| showMessage("An input or output exception occured while writing to socket"); | |
| } | |
| } | |
| /**A small function to display messages. | |
| * @param msg The message string to show. | |
| */ | |
| private void showMessage(String msg) | |
| { | |
| System.err.println("ClientSocketWriter: " + msg); | |
| } | |
| } | |