Skip to content

Commit 18b1b28

Browse files
Merge pull request #3 from shakeelmohamed/master
Tcp appender: add methods for changing the socket buffer size
2 parents ebfaf12 + c1392e7 commit 18b1b28

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/com/splunk/logging/SplunkRawTCPInput.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515

1616
public class SplunkRawTCPInput extends SplunkInput{
17+
private static int SOCKET_BUFFER_SIZE = 8 * 1024; // Default to 8192
1718

1819
// connection props
1920
private String host = "";
@@ -24,6 +25,14 @@ public class SplunkRawTCPInput extends SplunkInput{
2425
private OutputStream ostream;
2526
private Writer writerOut = null;
2627

28+
public static int getSocketBufferSize() {
29+
return SOCKET_BUFFER_SIZE;
30+
}
31+
32+
public static void setSocketBufferSize(int bufferSize) {
33+
SOCKET_BUFFER_SIZE = bufferSize;
34+
}
35+
2736
/**
2837
* Create a SplunkRawTCPInput object to send events to Splunk via Raw TCP
2938
*
@@ -50,6 +59,8 @@ private void openStream() throws Exception {
5059

5160
streamSocket = new Socket(host, port);
5261
if (streamSocket.isConnected()) {
62+
streamSocket.setSendBufferSize(getSocketBufferSize());
63+
streamSocket.setReceiveBufferSize(getSocketBufferSize());
5364
ostream = streamSocket.getOutputStream();
5465
writerOut = new OutputStreamWriter(ostream, "UTF8");
5566
}

0 commit comments

Comments
 (0)