Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
code
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ReadMailReallyFast
code
Commits
87d33bd1
Commit
87d33bd1
authored
2 years ago
by
Benny Baumann
Browse files
Options
Downloads
Patches
Plain Diff
add: Allow specifying target with socketaddress instance
parent
970283c7
No related branches found
No related tags found
1 merge request
!1
First unit tests
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/net/tcp_client.cpp
+18
-0
18 additions, 0 deletions
src/net/tcp_client.cpp
src/net/tcp_client.hpp
+14
-1
14 additions, 1 deletion
src/net/tcp_client.hpp
with
32 additions
and
1 deletion
src/net/tcp_client.cpp
+
18
−
0
View file @
87d33bd1
...
@@ -38,6 +38,24 @@ tcp_client::tcp_client(
...
@@ -38,6 +38,24 @@ tcp_client::tcp_client(
// TODO log created client
// TODO log created client
}
}
tcp_client
::
tcp_client
(
const
destructor_cb_type
destructor_cb_
,
auto_fd
&&
socket_fd
,
const
socketaddr
&
peer_address_
)
:
connection_client
{},
destructor_cb
(
destructor_cb_
),
peer_address
{
peer_address_
.
str
()},
port
{},
net_socket
(
std
::
forward
<
auto_fd
>
(
socket_fd
)),
io
{},
write_queue
{}
{
io
.
set
<
tcp_client
,
&
tcp_client
::
cb_ev
>
(
this
);
io
.
start
(
this
->
net_socket
.
get
(),
::
ev
::
READ
);
// TODO log created client
}
tcp_client
::
tcp_client
(
tcp_client
::
tcp_client
(
const
std
::
string
&
peer_address_
,
const
std
::
string
&
peer_address_
,
const
std
::
string
&
service_or_port
,
const
std
::
string
&
service_or_port
,
...
...
This diff is collapsed.
Click to expand it.
src/net/tcp_client.hpp
+
14
−
1
View file @
87d33bd1
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include
"net/async_fd.hpp"
#include
"net/async_fd.hpp"
#include
"net/connection_client.hpp"
#include
"net/connection_client.hpp"
#include
"net/ioqueue.hpp"
#include
"net/ioqueue.hpp"
#include
"net/socketaddress.hpp"
namespace
rmrf
::
net
{
namespace
rmrf
::
net
{
...
@@ -41,7 +42,7 @@ public:
...
@@ -41,7 +42,7 @@ public:
private:
private:
const
destructor_cb_type
destructor_cb
;
const
destructor_cb_type
destructor_cb
;
const
std
::
string
peer_address
;
std
::
string
peer_address
;
uint16_t
port
;
uint16_t
port
;
auto_fd
net_socket
;
auto_fd
net_socket
;
...
@@ -62,6 +63,18 @@ public:
...
@@ -62,6 +63,18 @@ public:
*/
*/
tcp_client
(
const
destructor_cb_type
destructor_cb_
,
auto_fd
&&
socket_fd
,
std
::
string
peer_address_
,
uint16_t
port_
);
tcp_client
(
const
destructor_cb_type
destructor_cb_
,
auto_fd
&&
socket_fd
,
std
::
string
peer_address_
,
uint16_t
port_
);
/**
* Construct a new TCP client using an already existing socket. This might be particulary useful if you've
* got a server and accept incoming connections.
*
* @brief Connect to a TCP server
* @param destructor_cb_ The callback that should be issued when the client closes or looses it's connection
* @param socket_fd A file descriptor for an already open socket to be wrapped by this client
* @param peer_address_ The address the socket is bound to on the other end of the connection
* @param port_ The bound port
*/
tcp_client
(
const
destructor_cb_type
destructor_cb_
,
auto_fd
&&
socket_fd
,
const
socketaddr
&
peer_address_
);
/**
/**
* Construct a new TCP client using an address and port pair.
* Construct a new TCP client using an address and port pair.
* @brief Connect to a TCP server
* @brief Connect to a TCP server
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment