List of usage examples for org.apache.commons.net.pop3 POP3Client setConnectTimeout
public void setConnectTimeout(int connectTimeout)
From source file:com.adaptris.mail.Pop3ReceiverFactory.java
@Override POP3Client preConnectConfigure(POP3Client client) throws MailException { try {//from ww w . j a v a2s . c om if (getConnectTimeout() != null) { client.setConnectTimeout(getConnectTimeout().intValue()); } if (getReceiveBufferSize() != null) { client.setReceiveBufferSize(getReceiveBufferSize().intValue()); } if (getSendBufferSize() != null) { client.setSendBufferSize(getSendBufferSize().intValue()); } if (getTimeout() != null) { client.setDefaultTimeout(getTimeout().intValue()); } } catch (SocketException e) { throw new MailException(e); } return client; }
From source file:me.schiz.jmeter.protocol.pop3.sampler.POP3Sampler.java
private SampleResult sampleConnect(SampleResult sr) { POP3Client client; if (getUseSSL()) { client = new POP3SClient(true); // } else if(getUseSTARTTLS()) { // client = new POP3SClient(false); } else {// w w w . j a v a 2 s . co m client = new POP3Client(); } StringBuilder requestBuilder = new StringBuilder(); try { //String request = "CONNECT \n"; requestBuilder.append("CONNECT\n"); requestBuilder.append("Host : " + getHostname() + ":" + getPort() + "\n"); requestBuilder.append("Connect Timeout: " + getConnectionTimeout() + "\n"); requestBuilder.append("Socket Timeout: " + getSoTimeout() + "\n"); requestBuilder.append("Client : " + getClient() + "\n"); if (getUseSSL()) requestBuilder.append("SSL : true\n"); else requestBuilder.append("SSL : false\n"); // if(getUseSTARTTLS()) request += "STARTTLS : true\n"; // else request += "STARTTLS : false\n"; sr.setRequestHeaders(requestBuilder.toString()); sr.sampleStart(); client.setConnectTimeout(getConnectionTimeout()); client.connect(getHostname(), getPort()); if (client.isConnected()) { SessionStorage.proto_type protoType = SessionStorage.proto_type.PLAIN; if (getUseSSL()) protoType = SessionStorage.proto_type.SSL; // if(getUseSSL() && !getUseSTARTTLS()) protoType = SessionStorage.proto_type.SSL; // if(!getUseSSL() && getUseSTARTTLS()) protoType = SessionStorage.proto_type.STARTTLS; SessionStorage.getInstance().putClient(getSOClient(), client, protoType); client.setSoTimeout(getSoTimeout()); client.setTcpNoDelay(getTcpNoDelay()); sr.setResponseCode(RC_200); sr.setResponseData(client.getReplyString().getBytes()); sr.setSuccessful(true); } else { sr.setResponseCode(RC_500); sr.setSuccessful(false); } } catch (SocketException se) { sr.setResponseMessage(se.toString()); sr.setSuccessful(false); sr.setResponseCode(se.getClass().getName()); log.error("client `" + client + "` ", se); } catch (IOException ioe) { sr.setResponseMessage(ioe.toString()); sr.setSuccessful(false); sr.setResponseCode(ioe.getClass().getName()); log.error("client `" + client + "` ", ioe); } sr.sampleEnd(); return sr; }