1 |
/* |
/* |
2 |
* LSCP Shell |
* LSCP Shell |
3 |
* |
* |
4 |
* Copyright (c) 2014 Christian Schoenebeck |
* Copyright (c) 2014 - 2016 Christian Schoenebeck |
5 |
* |
* |
6 |
* This program is part of LinuxSampler and released under the same terms. |
* This program is part of LinuxSampler and released under the same terms. |
7 |
*/ |
*/ |
145 |
bool LSCPClient::send(String s) { |
bool LSCPClient::send(String s) { |
146 |
//lscpLog("[send] '%s'\n", s.c_str()); |
//lscpLog("[send] '%s'\n", s.c_str()); |
147 |
if (!isConnected()) return false; |
if (!isConnected()) return false; |
148 |
int n = ::write(hSocket, &s[0], s.size()); |
int n = (int) ::write(hSocket, &s[0], s.size()); |
149 |
return n == s.size(); |
return n == s.size(); |
150 |
} |
} |
151 |
|
|
296 |
optional<String> LSCPClient::receiveLine() { |
optional<String> LSCPClient::receiveLine() { |
297 |
if (!isConnected()) return optional<String>::nothing; |
if (!isConnected()) return optional<String>::nothing; |
298 |
for (char c; true; ) { |
for (char c; true; ) { |
299 |
int n = ::read(hSocket, &c, 1); |
int n = (int) ::read(hSocket, &c, 1); |
300 |
if (n < 1) return optional<String>::nothing; |
if (n < 1) return optional<String>::nothing; |
301 |
if (c == '\r') continue; |
if (c == '\r') continue; |
302 |
if (c == '\n') { |
if (c == '\n') { |