Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Netlib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Daniel Müller
Netlib
Commits
00be314f
Commit
00be314f
authored
4 years ago
by
Daniel Müller
Browse files
Options
Downloads
Patches
Plain Diff
Add sendAllString function for TcpStream
- The sendAllString function sends the provided string bytes
parent
9b6c992b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inc/tcpstream.hpp
+12
-0
12 additions, 0 deletions
inc/tcpstream.hpp
src/tcpstream.cpp
+5
-0
5 additions, 0 deletions
src/tcpstream.cpp
with
17 additions
and
0 deletions
inc/tcpstream.hpp
+
12
−
0
View file @
00be314f
#ifndef _TCPSTREAM_HPP
#ifndef _TCPSTREAM_HPP
#define _TCPSTREAM_HPP
#define _TCPSTREAM_HPP
#include
<string>
#include
"sockaddr.hpp"
#include
"sockaddr.hpp"
/**
/**
...
@@ -119,6 +121,16 @@ public:
...
@@ -119,6 +121,16 @@ public:
*/
*/
void
sendAll
(
const
void
*
data
,
size_t
len
);
void
sendAll
(
const
void
*
data
,
size_t
len
);
/**
* @brief Send the given string data over the tcp connection. The function
* send all chars of the given string.
*
* If the sending fails, an exception is thrown.
*
* @param str The string that will be sent.
*/
void
sendAllString
(
const
std
::
string
&
str
);
/**
/**
* @brief Receive a maximum of len bytes of data from the tcp connection. It
* @brief Receive a maximum of len bytes of data from the tcp connection. It
* is possible that less than len bytes are received. This call will block
* is possible that less than len bytes are received. This call will block
...
...
This diff is collapsed.
Click to expand it.
src/tcpstream.cpp
+
5
−
0
View file @
00be314f
...
@@ -113,6 +113,11 @@ void TcpStream::sendAll(const void *data, size_t len)
...
@@ -113,6 +113,11 @@ void TcpStream::sendAll(const void *data, size_t len)
}
}
}
}
void
TcpStream
::
sendAllString
(
const
std
::
string
&
str
)
{
sendAll
(
str
.
c_str
(),
str
.
size
());
}
ssize_t
TcpStream
::
read
(
void
*
data
,
size_t
len
)
ssize_t
TcpStream
::
read
(
void
*
data
,
size_t
len
)
{
{
if
(
sockfd
==
0
)
if
(
sockfd
==
0
)
...
...
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