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