comparison src/org/tn5250j/framework/transport/SocketConnector.java @ 26:9ae1c889a64c tn5250

adding tn5250 files, native android logging
author Carl Byington <carl@five-ten-sg.com>
date Tue, 03 Jun 2014 12:16:46 -0700
parents 5949eb469a79
children b29b39f386a4
comparison
equal deleted inserted replaced
25:5949eb469a79 26:9ae1c889a64c
32 import org.tn5250j.TN5250jConstants; 32 import org.tn5250j.TN5250jConstants;
33 import android.util.Log; 33 import android.util.Log;
34 34
35 35
36 public class SocketConnector { 36 public class SocketConnector {
37 37 private static final String TAG = "SocketConnector";
38 String sslType = null; 38 String sslType = null;
39
40 TN5250jLogger logger;
41 39
42 /** 40 /**
43 * Creates a new instance that creates a plain socket by default. 41 * Creates a new instance that creates a plain socket by default.
44 */ 42 */
45 public SocketConnector() { 43 public SocketConnector() {
70 Socket socket = null; 68 Socket socket = null;
71 Exception ex = null; 69 Exception ex = null;
72 70
73 if (sslType == null || sslType.trim().length() == 0 || 71 if (sslType == null || sslType.trim().length() == 0 ||
74 sslType.toUpperCase().equals(TN5250jConstants.SSL_TYPE_NONE)) { 72 sslType.toUpperCase().equals(TN5250jConstants.SSL_TYPE_NONE)) {
75 logger.info("Creating Plain Socket"); 73 Log.i(TAG,"Creating Plain Socket");
76 try { 74 try {
77 // Use Socket Constructor!!! SocketFactory for jdk 1.4 75 // Use Socket Constructor!!! SocketFactory for jdk 1.4
78 socket = new Socket(destination,port); 76 socket = new Socket(destination,port);
79 } catch (Exception e) { 77 } catch (Exception e) {
80 ex = e; 78 ex = e;
81 } 79 }
82 } else { //SSL SOCKET 80 } else { //SSL SOCKET
83 81
84 logger.info("Creating SSL ["+sslType+"] Socket"); 82 Log.i(TAG,"Creating SSL ["+sslType+"] Socket");
85 83
86 SSLInterface sslIf = null; 84 SSLInterface sslIf = null;
87 85
88 try { 86 try {
89 sslIf = (SSLInterface) new SSLImplementation(bridge, manager); 87 sslIf = (SSLInterface) new SSLImplementation(bridge, manager);
97 socket = sslIf.createSSLSocket(destination, port); 95 socket = sslIf.createSSLSocket(destination, port);
98 } 96 }
99 } 97 }
100 98
101 if (ex != null) { 99 if (ex != null) {
102 logger.error(ex); 100 Log.e(TAG,ex);
103 } 101 }
104 if (socket == null) { 102 if (socket == null) {
105 logger.warn("No socket was created"); 103 Log.w(TAG,"No socket was created");
106 } 104 }
107 return socket; 105 return socket;
108 } 106 }
109 107
110 108