Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
50c73379
Commit
50c73379
authored
Aug 20, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net/SocketDescriptor: add GetType(), IsStream()
parent
b5c569cd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
SocketDescriptor.cxx
src/net/SocketDescriptor.cxx
+19
-0
SocketDescriptor.hxx
src/net/SocketDescriptor.hxx
+14
-0
No files found.
src/net/SocketDescriptor.cxx
View file @
50c73379
...
@@ -44,6 +44,25 @@
...
@@ -44,6 +44,25 @@
#include <errno.h>
#include <errno.h>
#include <string.h>
#include <string.h>
int
SocketDescriptor
::
GetType
()
const
noexcept
{
assert
(
IsDefined
());
int
type
;
socklen_t
size
=
sizeof
(
type
);
return
getsockopt
(
fd
,
SOL_SOCKET
,
SO_TYPE
,
(
char
*
)
&
type
,
&
size
)
==
0
?
type
:
-
1
;
}
bool
SocketDescriptor
::
IsStream
()
const
noexcept
{
return
GetType
()
==
SOCK_STREAM
;
}
#ifdef _WIN32
#ifdef _WIN32
void
void
...
...
src/net/SocketDescriptor.hxx
View file @
50c73379
...
@@ -82,6 +82,20 @@ public:
...
@@ -82,6 +82,20 @@ public:
using
FileDescriptor
::
IsValid
;
using
FileDescriptor
::
IsValid
;
using
FileDescriptor
::
IsSocket
;
using
FileDescriptor
::
IsSocket
;
#endif
#endif
/**
* Determine the socket type, i.e. SOCK_STREAM, SOCK_DGRAM or
* SOCK_SEQPACKET. Returns -1 on error.
*/
gcc_pure
int
GetType
()
const
noexcept
;
/**
* Is this a stream socket?
*/
gcc_pure
bool
IsStream
()
const
noexcept
;
using
FileDescriptor
::
Get
;
using
FileDescriptor
::
Get
;
using
FileDescriptor
::
Set
;
using
FileDescriptor
::
Set
;
using
FileDescriptor
::
Steal
;
using
FileDescriptor
::
Steal
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment