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
f5294414
Commit
f5294414
authored
Feb 13, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
server_socket: add method _add_fd()
parent
03664d04
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
0 deletions
+38
-0
server_socket.c
src/server_socket.c
+30
-0
server_socket.h
src/server_socket.h
+8
-0
No files found.
src/server_socket.c
View file @
f5294414
...
...
@@ -299,6 +299,36 @@ one_socket_new(unsigned serial, const struct sockaddr *address,
return
s
;
}
bool
server_socket_add_fd
(
struct
server_socket
*
ss
,
int
fd
,
GError
**
error_r
)
{
assert
(
ss
!=
NULL
);
assert
(
ss
->
sockets_tail_r
!=
NULL
);
assert
(
*
ss
->
sockets_tail_r
==
NULL
);
assert
(
fd
>=
0
);
struct
sockaddr_storage
address
;
socklen_t
address_length
;
if
(
getsockname
(
fd
,
(
struct
sockaddr
*
)
&
address
,
&
address_length
)
<
0
)
{
g_set_error
(
error_r
,
server_socket_quark
(),
errno
,
"Failed to get socket address: %s"
,
g_strerror
(
errno
));
return
false
;
}
struct
one_socket
*
s
=
one_socket_new
(
ss
->
next_serial
,
(
struct
sockaddr
*
)
&
address
,
address_length
);
s
->
parent
=
ss
;
*
ss
->
sockets_tail_r
=
s
;
ss
->
sockets_tail_r
=
&
s
->
next
;
set_fd
(
s
,
fd
);
return
true
;
}
static
struct
one_socket
*
server_socket_add_address
(
struct
server_socket
*
ss
,
const
struct
sockaddr
*
address
,
...
...
src/server_socket.h
View file @
f5294414
...
...
@@ -44,6 +44,14 @@ void
server_socket_close
(
struct
server_socket
*
ss
);
/**
* Add a socket descriptor that is accepting connections. After this
* has been called, don't call server_socket_open(), because the
* socket is already open.
*/
bool
server_socket_add_fd
(
struct
server_socket
*
ss
,
int
fd
,
GError
**
error_r
);
/**
* Add a listener on a port on all interfaces.
*
* @param port the TCP port
...
...
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