Utilizing Socket utilities to handle TCP and HTTP socket connections
The ETL Development API provides various methods to handle socket connections that are present in the following class:
- (com.neptuny.cpit.etl.util.SocketUtil)
You can connect to a remote host that supports TCP and UDP connections using the following method:
- connect(protocol, host, port)
Once the connection is established, the following methods can be used to send and receive data through the socket:
- send(message)
- receive(max_row) (the max_row parameter is optional)
The following code examples illustrate the usage of methods discussed so far in this section:
SocketUtil s = new SocketUtil();
# set the connection timeout
s.setTimeout(200);
# connect to server
s.connect("tcp","HOST","PORT");
# receive 4 lines from socket
ArrayList<String> retline = s.receive(4);
s.send("a message");
s.close();
Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*