Mercurial > hg > monetdb-java
comparison src/main/java/org/monetdb/merovingian/Control.java @ 630:ea8e3d011632
Allow setting socket read timeout on Control
(contributed by Wouter Alink)
author | Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com> |
---|---|
date | Fri, 21 Jan 2022 10:41:34 +0100 (2022-01-21) |
parents | 6aa38e8c0f2d |
children | 0674e6fb4bdd |
comparison
equal
deleted
inserted
replaced
629:24c49b65bc3b | 630:ea8e3d011632 |
---|---|
49 private final int port; | 49 private final int port; |
50 /** The passphrase to use when connecting */ | 50 /** The passphrase to use when connecting */ |
51 private final String passphrase; | 51 private final String passphrase; |
52 /** The file we should write MapiSocket debuglog to */ | 52 /** The file we should write MapiSocket debuglog to */ |
53 private String debug; | 53 private String debug; |
54 private int soTimeout = -1; /* -1 means not initialized */ | |
54 | 55 |
55 | 56 |
56 /** | 57 /** |
57 * Constructs a new Control object. | 58 * Constructs a new Control object. |
58 * | 59 * |
67 { | 68 { |
68 this.host = host; | 69 this.host = host; |
69 this.port = port; | 70 this.port = port; |
70 this.passphrase = passphrase; | 71 this.passphrase = passphrase; |
71 } | 72 } |
73 | |
74 /** | |
75 * Sets the socket timeout. | |
76 * | |
77 * @param timeout (in milliseconds) Use -1 to unset timeout (and use default) | |
78 */ | |
79 public void setSoTimeout(int timeout) { | |
80 soTimeout = timeout; | |
81 } | |
72 | 82 |
73 /** | 83 /** |
74 * Instructs to write a MCL protocol debug log to the given file. | 84 * Instructs to write a MCL protocol debug log to the given file. |
75 * This affects any newly performed command, and can be changed | 85 * This affects any newly performed command, and can be changed |
76 * inbetween commands. Passing null to this method disables the | 86 * inbetween commands. Passing null to this method disables the |
119 BufferedMCLReader min; | 129 BufferedMCLReader min; |
120 BufferedMCLWriter mout; | 130 BufferedMCLWriter mout; |
121 MapiSocket ms = new MapiSocket(); | 131 MapiSocket ms = new MapiSocket(); |
122 ms.setDatabase("merovingian"); | 132 ms.setDatabase("merovingian"); |
123 ms.setLanguage("control"); | 133 ms.setLanguage("control"); |
134 if (soTimeout != -1) | |
135 ms.setSoTimeout(soTimeout); | |
124 if (debug != null) | 136 if (debug != null) |
125 ms.debug(debug); | 137 ms.debug(debug); |
126 try { | 138 try { |
127 ms.connect(host, port, "monetdb", passphrase); | 139 ms.connect(host, port, "monetdb", passphrase); |
128 min = ms.getReader(); | 140 min = ms.getReader(); |