Skip to content
This repository was archived by the owner on Nov 15, 2022. It is now read-only.

Commit ab1b475

Browse files
Paweł NiedzielskiSteveb-p
authored andcommitted
Always end TCP message with newline character
1 parent 5712fe1 commit ab1b475

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/InfluxDB/Driver/AbstractSocketDriver.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ public function write($data = null)
7575
$this->createStream();
7676
}
7777

78-
$this->doWrite($data);
78+
if ($data !== null) {
79+
$this->doWrite($data);
80+
}
7981
}
8082

8183
/**
@@ -85,9 +87,9 @@ abstract public function isSuccess();
8587

8688
/**
8789
* Perform write to socket
88-
* @param mixed|null $data
90+
* @param mixed $data
8991
*/
90-
abstract protected function doWrite($data = null);
92+
abstract protected function doWrite($data);
9193

9294
/**
9395
* Create the resource stream

src/InfluxDB/Driver/TCP.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ protected function createStream()
3737
/**
3838
* {@inheritdoc}
3939
*/
40-
protected function doWrite($data = null)
40+
protected function doWrite($data)
4141
{
42-
$this->result = false !== @fwrite($this->stream, $data);
42+
$this->result = false !== @fwrite($this->stream, "$data\n");
4343
}
4444
}

src/InfluxDB/Driver/UDP.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function createStream()
3434
/**
3535
* {@inheritdoc}
3636
*/
37-
protected function doWrite($data = null)
37+
protected function doWrite($data)
3838
{
3939
@stream_socket_sendto($this->stream, $data);
4040
}

0 commit comments

Comments
 (0)