2626import java .io .IOException ;
2727import java .net .InetSocketAddress ;
2828import java .net .Socket ;
29- import java .net .SocketAddress ;
3029import java .nio .ByteBuffer ;
3130import java .util .Map ;
3231
@@ -38,8 +37,6 @@ public class RawSocketSender implements Sender {
3837
3938 private MessagePack msgpack ;
4039
41- private SocketAddress server ;
42-
4340 private Socket socket ;
4441
4542 private int timeout ;
@@ -52,6 +49,10 @@ public class RawSocketSender implements Sender {
5249
5350 private String name ;
5451
52+ private final String host ;
53+
54+ private final int port ;
55+
5556 private ErrorHandler errorHandler = DEFAULT_ERROR_HANDLER ;
5657
5758 public RawSocketSender () {
@@ -71,7 +72,8 @@ public RawSocketSender(String host, int port, int timeout, int bufferCapacity, R
7172 msgpack = new MessagePack ();
7273 msgpack .register (Event .class , Event .EventTemplate .INSTANCE );
7374 pendings = ByteBuffer .allocate (bufferCapacity );
74- server = new InetSocketAddress (host , port );
75+ this .host = host ;
76+ this .port = port ;
7577 this .reconnector = reconnector ;
7678 name = String .format ("%s_%d_%d_%d" , host , port , timeout , bufferCapacity );
7779 this .timeout = timeout ;
@@ -80,7 +82,7 @@ public RawSocketSender(String host, int port, int timeout, int bufferCapacity, R
8082 private void connect () throws IOException {
8183 try {
8284 socket = new Socket ();
83- socket .connect (server , timeout );
85+ socket .connect (new InetSocketAddress ( host , port ) , timeout );
8486 out = new BufferedOutputStream (socket .getOutputStream ());
8587 } catch (IOException e ) {
8688 throw e ;
@@ -153,7 +155,7 @@ private boolean flushBuffer() {
153155 if (pendings .position () == 0 ) {
154156 return true ;
155157 } else {
156- LOG .error ("Cannot send logs to " + server .toString ());
158+ LOG .error ("Cannot send logs to " + socket . getInetAddress () .toString ());
157159 }
158160 }
159161
0 commit comments