server: add a HELLO handshake
[fanfix.git] / src / be / nikiroo / utils / serial / server / ConnectActionClientString.java
CommitLineData
79ce1a49
NR
1package be.nikiroo.utils.serial.server;
2
3import java.io.IOException;
4import java.net.Socket;
f4053377 5import java.net.UnknownHostException;
79ce1a49 6
79ce1a49
NR
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 */
15public class ConnectActionClientString extends ConnectActionClient {
16 /**
340e6065 17 * Create a new {@link ConnectActionClientString}.
79ce1a49
NR
18 *
19 * @param s
20 * the socket to bind to
8468bb79
NR
21 * @param key
22 * an optional key to encrypt all the communications (if NULL,
23 * everything will be sent in clear text)
79ce1a49 24 */
8468bb79
NR
25 public ConnectActionClientString(Socket s, String key) {
26 super(s, key);
79ce1a49
NR
27 }
28
29 /**
340e6065 30 * Create a new {@link ConnectActionClientString}.
79ce1a49
NR
31 *
32 * @param host
33 * the host to bind to
34 * @param port
35 * the port to bind to
8468bb79
NR
36 * @param key
37 * an optional key to encrypt all the communications (if NULL,
38 * everything will be sent in clear text)
79ce1a49
NR
39 *
40 * @throws IOException
f4053377
NR
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
79ce1a49 47 */
8468bb79 48 public ConnectActionClientString(String host, int port, String key)
79ce1a49 49 throws IOException {
8468bb79 50 super(host, port, key);
79ce1a49
NR
51 }
52
79ce1a49
NR
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}