[Positioning] UDP & TCPEvAAL: send '\0'
Send the final null character of the CSV string.
This commit is contained in:
parent
de74213102
commit
c61c4b3a22
|
@ -123,8 +123,9 @@ area_of_interest_number(const Point3D &position) const
|
|||
*/
|
||||
bool OutputTCPSocketEvAAL::send_data(const string &data) const
|
||||
{
|
||||
ssize_t nsent = send(sockfd, data.c_str(), data.size(), 0) ;
|
||||
if (nsent != static_cast<ssize_t>(data.size()))
|
||||
unsigned int data_len = data.size() + 1 ; // +1 for the '\0'
|
||||
ssize_t nsent = send(sockfd, data.c_str(), data_len, 0) ;
|
||||
if (nsent != static_cast<ssize_t>(data_len))
|
||||
{
|
||||
perror("Error sending result data through the TCPEvAAL socket") ;
|
||||
return false ;
|
||||
|
|
|
@ -45,10 +45,11 @@ bool OutputUDPSocket::init_socket()
|
|||
*/
|
||||
bool OutputUDPSocket::send_data(const string &data) const
|
||||
{
|
||||
ssize_t nsent = sendto(sockfd, data.c_str(), data.size(), 0,
|
||||
unsigned int data_len = data.size() + 1 ; // +1 for the '\0'
|
||||
ssize_t nsent = sendto(sockfd, data.c_str(), data_len, 0,
|
||||
(struct sockaddr *) &server_info,
|
||||
sizeof(server_info)) ;
|
||||
if (nsent != static_cast<ssize_t>(data.size()))
|
||||
if (nsent != static_cast<ssize_t>(data_len))
|
||||
{
|
||||
perror("Error sending result data through the UDP socket") ;
|
||||
return false ;
|
||||
|
|
Loading…
Reference in New Issue