Skip to content

Commit cc4446d

Browse files
authored
Merge pull request #10 from sumboid/multiple-zmq-fixes
Multiple zmq fixes
2 parents 64dff36 + c9981b7 commit cc4446d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/main/java/com/cisco/trex/stateless/TRexTransport.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class TRexTransport {
1616

1717
private static final Logger LOGGER = LoggerFactory.getLogger(TRexTransport.class);
1818

19-
public static final int DEFAULT_RECEIVE_TIMEOUT = 3000;
19+
public static final int DEFAULT_TIMEOUT = 3000;
2020

2121
private final String connectionString;
2222

@@ -30,12 +30,13 @@ public class TRexTransport {
3030

3131
private String port;
3232

33-
public TRexTransport(String host, String port, int receiveTimeout) {
33+
public TRexTransport(String host, String port, int timeout) {
3434
this.host = host;
3535
this.port = port;
3636
zmqSocket = zmqCtx.socket(ZMQ.REQ);
37-
int timeout = receiveTimeout == 0 ? DEFAULT_RECEIVE_TIMEOUT : receiveTimeout;
38-
zmqSocket.setReceiveTimeOut(timeout);
37+
int actualTimeout = timeout <= 0 ? DEFAULT_TIMEOUT : timeout;
38+
zmqSocket.setReceiveTimeOut(actualTimeout);
39+
zmqSocket.setSendTimeOut(actualTimeout);
3940
connectionString = protocol + "://"+ this.host +":" + this.port;
4041
zmqSocket.connect(connectionString);
4142
}
@@ -81,6 +82,7 @@ public String getPort() {
8182

8283
synchronized public void close() {
8384
zmqSocket.disconnect(connectionString);
85+
zmqSocket.close();
8486
zmqCtx.close();
8587
}
8688

0 commit comments

Comments
 (0)