Commit | Line | Data |
---|---|---|
79ce1a49 NR |
1 | package be.nikiroo.utils.serial.server; |
2 | ||
3 | import java.io.IOException; | |
4 | import java.net.Socket; | |
f4053377 | 5 | import 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 | */ | |
15 | public class ConnectActionClientObject extends ConnectActionClient { | |
16 | /** | |
340e6065 | 17 | * Create a new {@link ConnectActionClientObject} . |
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 ConnectActionClientObject(Socket s, String key) { |
26 | super(s, key); | |
79ce1a49 NR |
27 | } |
28 | ||
29 | /** | |
340e6065 | 30 | * Create a new {@link ConnectActionClientObject}. |
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 ConnectActionClientObject(String host, int port, String key) |
79ce1a49 | 49 | throws IOException { |
8468bb79 | 50 | super(host, port, key); |
79ce1a49 NR |
51 | } |
52 | ||
79ce1a49 NR |
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 | } |