From 707f6f4441b56ad59bf8466224263af7104e8d93 Mon Sep 17 00:00:00 2001 From: Yaude Date: Sat, 19 May 2012 16:41:28 +0300 Subject: [PATCH 1/3] Add the timeout parameter in connectAndBind method, createConnection, to take it in count --- jsmpp/src/main/java/org/jsmpp/session/SMPPSession.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jsmpp/src/main/java/org/jsmpp/session/SMPPSession.java b/jsmpp/src/main/java/org/jsmpp/session/SMPPSession.java index 557b996..460a60d 100644 --- a/jsmpp/src/main/java/org/jsmpp/session/SMPPSession.java +++ b/jsmpp/src/main/java/org/jsmpp/session/SMPPSession.java @@ -219,7 +219,7 @@ public String connectAndBind(String host, int port, throw new IOException("Failed connecting"); } - conn = connFactory.createConnection(host, port); + conn = connFactory.createConnection(host, port, timeout); logger.info("Connected"); conn.setSoTimeout(getEnquireLinkTimer()); From aa1ab25b1fcfb5dafc2828c6c097040be38af04f Mon Sep 17 00:00:00 2001 From: Yaude Date: Sat, 19 May 2012 16:43:31 +0300 Subject: [PATCH 2/3] Ajout de l'interface createConnection(host, port, timeout) --- .../java/org/jsmpp/session/connection/ConnectionFactory.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jsmpp/src/main/java/org/jsmpp/session/connection/ConnectionFactory.java b/jsmpp/src/main/java/org/jsmpp/session/connection/ConnectionFactory.java index 88c445e..406a774 100644 --- a/jsmpp/src/main/java/org/jsmpp/session/connection/ConnectionFactory.java +++ b/jsmpp/src/main/java/org/jsmpp/session/connection/ConnectionFactory.java @@ -22,4 +22,5 @@ */ public interface ConnectionFactory { Connection createConnection(String host, int port) throws IOException; + Connection createConnection(String host, int port, long timeout) throws IOException; } From d2369bd34cd300346b9372fb4e9d2e8aee191eee Mon Sep 17 00:00:00 2001 From: Yaude Date: Sat, 19 May 2012 16:47:59 +0300 Subject: [PATCH 3/3] Add socket creation with timeout value --- .../connection/socket/SocketConnectionFactory.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jsmpp/src/main/java/org/jsmpp/session/connection/socket/SocketConnectionFactory.java b/jsmpp/src/main/java/org/jsmpp/session/connection/socket/SocketConnectionFactory.java index efefea4..53e94a9 100644 --- a/jsmpp/src/main/java/org/jsmpp/session/connection/socket/SocketConnectionFactory.java +++ b/jsmpp/src/main/java/org/jsmpp/session/connection/socket/SocketConnectionFactory.java @@ -15,6 +15,7 @@ package org.jsmpp.session.connection.socket; import java.io.IOException; +import java.net.InetSocketAddress; import java.net.Socket; import org.jsmpp.session.connection.Connection; @@ -38,4 +39,11 @@ public Connection createConnection(String host, int port) throws IOException { return new SocketConnection(new Socket(host, port)); } + public Connection createConnection(String host, int port, long timeout) + throws IOException { + Socket soc = new Socket(); + InetSocketAddress endpoint = new InetSocketAddress(host, port); + soc.connect(endpoint, (int)timeout); + return new SocketConnection(soc); + } }