Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
cf6c871b
Commit
cf6c871b
authored
Jul 03, 2015
by
Stephan Holljes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavf/network: split ff_listen_bind into ff_listen and ff_accept
Signed-off-by:
Stephan Holljes
<
klaxa1337@googlemail.com
>
parent
5870b3d2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
6 deletions
+41
-6
network.c
libavformat/network.c
+21
-6
network.h
libavformat/network.h
+20
-0
No files found.
libavformat/network.c
View file @
cf6c871b
...
...
@@ -187,12 +187,11 @@ int ff_socket(int af, int type, int proto)
return
fd
;
}
int
ff_listen
_bind
(
int
fd
,
const
struct
sockaddr
*
addr
,
socklen_t
addrlen
,
int
timeout
,
URLContext
*
h
)
int
ff_listen
(
int
fd
,
const
struct
sockaddr
*
addr
,
socklen_t
addrlen
)
{
int
ret
;
int
reuse
=
1
;
struct
pollfd
lp
=
{
fd
,
POLLIN
,
0
};
if
(
setsockopt
(
fd
,
SOL_SOCKET
,
SO_REUSEADDR
,
&
reuse
,
sizeof
(
reuse
)))
{
av_log
(
NULL
,
AV_LOG_WARNING
,
"setsockopt(SO_REUSEADDR) failed
\n
"
);
}
...
...
@@ -203,6 +202,13 @@ int ff_listen_bind(int fd, const struct sockaddr *addr,
ret
=
listen
(
fd
,
1
);
if
(
ret
)
return
ff_neterrno
();
return
ret
;
}
int
ff_accept
(
int
fd
,
int
timeout
,
URLContext
*
h
)
{
int
ret
;
struct
pollfd
lp
=
{
fd
,
POLLIN
,
0
};
ret
=
ff_poll_interrupt
(
&
lp
,
1
,
timeout
,
&
h
->
interrupt_callback
);
if
(
ret
<
0
)
...
...
@@ -211,15 +217,24 @@ int ff_listen_bind(int fd, const struct sockaddr *addr,
ret
=
accept
(
fd
,
NULL
,
NULL
);
if
(
ret
<
0
)
return
ff_neterrno
();
closesocket
(
fd
);
if
(
ff_socket_nonblock
(
ret
,
1
)
<
0
)
av_log
(
NULL
,
AV_LOG_DEBUG
,
"ff_socket_nonblock failed
\n
"
);
return
ret
;
}
int
ff_listen_bind
(
int
fd
,
const
struct
sockaddr
*
addr
,
socklen_t
addrlen
,
int
timeout
,
URLContext
*
h
)
{
int
ret
;
if
((
ret
=
ff_listen
(
fd
,
addr
,
addrlen
))
<
0
)
return
ret
;
if
((
ret
=
ff_accept
(
fd
,
timeout
,
h
))
<
0
)
return
ret
;
closesocket
(
fd
);
return
ret
;
}
int
ff_listen_connect
(
int
fd
,
const
struct
sockaddr
*
addr
,
socklen_t
addrlen
,
int
timeout
,
URLContext
*
h
,
int
will_try_next
)
...
...
libavformat/network.h
View file @
cf6c871b
...
...
@@ -254,6 +254,26 @@ int ff_listen_bind(int fd, const struct sockaddr *addr,
socklen_t
addrlen
,
int
timeout
,
URLContext
*
h
);
/**
* Bind to a file descriptor to an address without accepting connections.
* @param fd First argument of bind().
* @param addr Second argument of bind().
* @param addrlen Third argument of bind().
* @return 0 on success or an AVERROR on failure.
*/
int
ff_listen
(
int
fd
,
const
struct
sockaddr
*
addr
,
socklen_t
addrlen
);
/**
* Poll for a single connection on the passed file descriptor.
* @param fd The listening socket file descriptor.
* @param timeout Polling timeout in milliseconds.
* @param h URLContext providing interrupt check
* callback and logging context.
* @return A non-blocking file descriptor on success
* or an AVERROR on failure.
*/
int
ff_accept
(
int
fd
,
int
timeout
,
URLContext
*
h
);
/**
* Connect to a file descriptor and poll for result.
*
...
...
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