server: add a HELLO handshake
[fanfix.git] / src / be / nikiroo / utils / serial / server / ConnectActionClientObject.java
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 ConnectActionClientObject extends ConnectActionClient {
16 /**
17 * Create a new {@link ConnectActionClientObject} .
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 ConnectActionClientObject(Socket s, String key) {
26 super(s, key);
27 }
28
29 /**
30 * Create a new {@link ConnectActionClientObject}.
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 ConnectActionClientObject(String host, int port, String key)
49 throws IOException {
50 super(host, port, key);
51 }
52
53 /**
54 * Serialise and send the given object to the server (and return the
55 * deserialised answer).
56 *
57 * @param data
58 * the data to send
59 *
60 * @return the answer, which can be NULL
61 *
62 * @throws IOException
63 * in case of I/O error
64 * @throws NoSuchFieldException
65 * if the serialised data contains information about a field
66 * which does actually not exist in the class we know of
67 * @throws NoSuchMethodException
68 * if a class described in the serialised data cannot be created
69 * because it is not compatible with this code
70 * @throws ClassNotFoundException
71 * if a class described in the serialised data cannot be found
72 */
73 public Object send(Object data) throws IOException, NoSuchFieldException,
74 NoSuchMethodException, ClassNotFoundException {
75 return action.sendObject(data);
76 }
77 }