Skip to content

Commit ea4c085

Browse files
committed
ability to use a socket factory rather always use Socket()
1 parent 3aee72f commit ea4c085

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/main/com/mongodb/DBPort.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ boolean _open()
199199
IOException lastError = null;
200200

201201
try {
202-
_socket = new Socket();
202+
_socket = _options.socketFactory.createSocket();
203203
_socket.connect( _addr , _options.connectTimeout );
204204

205205
_socket.setTcpNoDelay( ! USE_NAGLE );

src/main/com/mongodb/MongoOptions.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package com.mongodb;
2020

21+
import javax.net.SocketFactory;
2122

2223
/**
2324
* Various settings for the driver
@@ -41,7 +42,9 @@ public void reset(){
4142
w = 0;
4243
wtimeout = 0;
4344
fsync = false;
45+
j = false;
4446
dbDecoderFactory = DefaultDBDecoder.FACTORY;
47+
socketFactory = SocketFactory.getDefault();
4548
}
4649

4750
/**
@@ -166,6 +169,12 @@ else if (safe)
166169
*/
167170
public boolean j;
168171

172+
/**
173+
* sets the socket factory for creating sockets to mongod
174+
* Default is SocketFactory.getDefault()
175+
*/
176+
public SocketFactory socketFactory;
177+
169178
public String toString(){
170179
StringBuilder buf = new StringBuilder();
171180
buf.append( "description=" ).append( description ).append( ", " );

0 commit comments

Comments
 (0)