Apollo
10.0
自动驾驶开放平台
tcp_stream.h
浏览该文件的文档.
1
/******************************************************************************
2
* Copyright 2017 The Apollo Authors. All Rights Reserved.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*****************************************************************************/
16
17
#pragma once
18
19
namespace
apollo
{
20
namespace
drivers {
21
namespace
gnss {
22
23
class
TcpStream
:
public
Stream
{
24
typedef
uint16_t be16_t;
25
typedef
uint32_t be32_t;
26
27
public
:
28
TcpStream
(
const
char
*address, uint16_t port, uint32_t timeout_usec,
29
bool
auto_reconnect =
true
);
30
~TcpStream
();
31
32
virtual
bool
Connect
();
33
virtual
bool
Disconnect
();
34
virtual
size_t
read
(uint8_t *buffer,
size_t
max_length);
35
virtual
size_t
write
(
const
uint8_t *data,
size_t
length);
36
37
private
:
38
bool
Reconnect();
39
bool
Readable(uint32_t timeout_us);
40
TcpStream
() {}
41
void
open();
42
void
close();
43
bool
InitSocket();
44
be16_t peer_port_ = 0;
45
be32_t peer_addr_ = 0;
46
uint32_t timeout_usec_ = 0;
47
int
sockfd_ = -1;
48
int
errno_ = 0;
49
bool
auto_reconnect_ =
false
;
50
};
51
52
}
// namespace gnss
53
}
// namespace drivers
54
}
// namespace apollo
apollo::drivers::gnss::Stream
Definition
stream.h:36
apollo::drivers::gnss::TcpStream
Definition
tcp_stream.h:23
apollo::drivers::gnss::TcpStream::read
virtual size_t read(uint8_t *buffer, size_t max_length)
Definition
tcp_stream.cc:245
apollo::drivers::gnss::TcpStream::Connect
virtual bool Connect()
Definition
tcp_stream.cc:141
apollo::drivers::gnss::TcpStream::write
virtual size_t write(const uint8_t *data, size_t length)
Definition
tcp_stream.cc:286
apollo::drivers::gnss::TcpStream::Disconnect
virtual bool Disconnect()
Definition
tcp_stream.cc:235
apollo::drivers::gnss::TcpStream::~TcpStream
~TcpStream()
Definition
tcp_stream.cc:45
apollo
class register implement
Definition
arena_queue.h:37
modules
drivers
gnss
stream
tcp_stream.h