| 1 | package be.nikiroo.utils.serial.server; |
| 2 | |
| 3 | import java.io.IOException; |
| 4 | import java.net.Socket; |
| 5 | import java.net.UnknownHostException; |
| 6 | |
| 7 | import be.nikiroo.utils.Version; |
| 8 | |
| 9 | /** |
| 10 | * Class used for the client basic handling. |
| 11 | * <p> |
| 12 | * It represents a single action: a client is expected to only execute one |
| 13 | * action. |
| 14 | * |
| 15 | * @author niki |
| 16 | */ |
| 17 | public class ConnectActionClientString extends ConnectActionClient { |
| 18 | /** |
| 19 | * Create a new {@link ConnectActionClientString} with the current |
| 20 | * application version (see {@link Version#getCurrentVersion()}) as the |
| 21 | * client version. |
| 22 | * |
| 23 | * @param s |
| 24 | * the socket to bind to |
| 25 | * @param key |
| 26 | * an optional key to encrypt all the communications (if NULL, |
| 27 | * everything will be sent in clear text) |
| 28 | */ |
| 29 | public ConnectActionClientString(Socket s, String key) { |
| 30 | super(s, key); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Create a new {@link ConnectActionClientString} with the current |
| 35 | * application version (see {@link Version#getCurrentVersion()}) as the |
| 36 | * client version. |
| 37 | * |
| 38 | * @param host |
| 39 | * the host to bind to |
| 40 | * @param port |
| 41 | * the port to bind to |
| 42 | * @param key |
| 43 | * an optional key to encrypt all the communications (if NULL, |
| 44 | * everything will be sent in clear text) |
| 45 | * |
| 46 | * @throws IOException |
| 47 | * in case of I/O error |
| 48 | * @throws UnknownHostException |
| 49 | * if the IP address of the host could not be determined |
| 50 | * @throws IllegalArgumentException |
| 51 | * if the port parameter is outside the specified range of valid |
| 52 | * port values, which is between 0 and 65535, inclusive |
| 53 | */ |
| 54 | public ConnectActionClientString(String host, int port, String key) |
| 55 | throws IOException { |
| 56 | super(host, port, key); |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Send the given object to the server (and return the answer). |
| 61 | * |
| 62 | * @param data |
| 63 | * the data to send |
| 64 | * |
| 65 | * @return the answer, which can be NULL |
| 66 | * |
| 67 | * @throws IOException |
| 68 | * in case of I/O error |
| 69 | */ |
| 70 | public String send(String data) throws IOException { |
| 71 | return action.sendString(data); |
| 72 | } |
| 73 | } |