Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
af9809f0
Commit
af9809f0
authored
Sep 04, 2008
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed socket setup in net_ListenSingle.
(it was used by net_OpenDgram when no server is specified).
parent
3228d8b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
51 deletions
+45
-51
src/network/udp.c
src/network/udp.c
+45
-51
No files found.
src/network/udp.c
View file @
af9809f0
...
...
@@ -97,6 +97,47 @@
extern
int
net_Socket
(
vlc_object_t
*
p_this
,
int
i_family
,
int
i_socktype
,
int
i_protocol
);
/* */
static
int
net_SetupDgramSocket
(
vlc_object_t
*
p_obj
,
int
fd
,
const
struct
addrinfo
*
ptr
)
{
#ifdef SO_REUSEPORT
setsockopt
(
fd
,
SOL_SOCKET
,
SO_REUSEPORT
,
&
(
int
){
1
},
sizeof
(
int
));
#endif
#ifdef SO_RCVBUF
/* Increase the receive buffer size to 1/2MB (8Mb/s during 1/2s)
* to avoid packet loss caused in case of scheduling hiccups */
setsockopt
(
fd
,
SOL_SOCKET
,
SO_RCVBUF
,
(
void
*
)
&
(
int
){
0x80000
},
sizeof
(
int
));
setsockopt
(
fd
,
SOL_SOCKET
,
SO_SNDBUF
,
(
void
*
)
&
(
int
){
0x80000
},
sizeof
(
int
));
#endif
#if defined (WIN32) || defined (UNDER_CE)
if
(
net_SockAddrIsMulticast
(
ptr
->
ai_addr
,
ptr
->
ai_addrlen
)
&&
(
sizeof
(
struct
sockaddr_storage
)
>=
ptr
->
ai_addrlen
))
{
// This works for IPv4 too - don't worry!
struct
sockaddr_in6
dumb
=
{
.
sin6_family
=
ptr
->
ai_addr
->
sa_family
,
.
sin6_port
=
((
struct
sockaddr_in
*
)(
ptr
->
ai_addr
))
->
sin_port
};
bind
(
fd
,
(
struct
sockaddr
*
)
&
dumb
,
ptr
->
ai_addrlen
);
}
else
#endif
if
(
bind
(
fd
,
ptr
->
ai_addr
,
ptr
->
ai_addrlen
))
{
msg_Err
(
p_obj
,
"socket bind error (%m)"
);
net_Close
(
fd
);
return
-
1
;
}
return
fd
;
}
/* */
static
int
net_ListenSingle
(
vlc_object_t
*
obj
,
const
char
*
host
,
int
port
,
int
family
,
int
protocol
)
{
...
...
@@ -145,26 +186,9 @@ static int net_ListenSingle (vlc_object_t *obj, const char *host, int port,
}
}
/* Bind the socket */
#if defined (WIN32) || defined (UNDER_CE)
if
(
net_SockAddrIsMulticast
(
ptr
->
ai_addr
,
ptr
->
ai_addrlen
)
&&
(
sizeof
(
struct
sockaddr_storage
)
>=
ptr
->
ai_addrlen
))
{
struct
sockaddr_in6
dumb
=
{
.
sin6_family
=
ptr
->
ai_addr
->
sa_family
,
.
sin6_port
=
((
struct
sockaddr_in
*
)(
ptr
->
ai_addr
))
->
sin_port
};
bind
(
fd
,
(
struct
sockaddr
*
)
&
dumb
,
ptr
->
ai_addrlen
);
}
else
#endif
if
(
bind
(
fd
,
ptr
->
ai_addr
,
ptr
->
ai_addrlen
))
{
msg_Err
(
obj
,
"socket bind error (%m)"
);
net_Close
(
fd
);
fd
=
net_SetupDgramSocket
(
obj
,
fd
,
ptr
);
if
(
fd
==
-
1
)
continue
;
}
if
(
net_SockAddrIsMulticast
(
ptr
->
ai_addr
,
ptr
->
ai_addrlen
)
&&
net_Subscribe
(
obj
,
fd
,
ptr
->
ai_addr
,
ptr
->
ai_addrlen
))
...
...
@@ -753,39 +777,9 @@ int __net_OpenDgram( vlc_object_t *obj, const char *psz_bind, int i_bind,
if
(
fd
==
-
1
)
continue
;
// usually, address family not supported
#ifdef SO_REUSEPORT
setsockopt
(
fd
,
SOL_SOCKET
,
SO_REUSEPORT
,
&
(
int
){
1
},
sizeof
(
int
));
#endif
#ifdef SO_RCVBUF
/* Increase the receive buffer size to 1/2MB (8Mb/s during 1/2s)
* to avoid packet loss caused in case of scheduling hiccups */
setsockopt
(
fd
,
SOL_SOCKET
,
SO_RCVBUF
,
(
void
*
)
&
(
int
){
0x80000
},
sizeof
(
int
));
setsockopt
(
fd
,
SOL_SOCKET
,
SO_SNDBUF
,
(
void
*
)
&
(
int
){
0x80000
},
sizeof
(
int
));
#endif
#if defined (WIN32) || defined (UNDER_CE)
if
(
net_SockAddrIsMulticast
(
ptr
->
ai_addr
,
ptr
->
ai_addrlen
)
&&
(
sizeof
(
struct
sockaddr_storage
)
>=
ptr
->
ai_addrlen
))
{
// This works for IPv4 too - don't worry!
struct
sockaddr_in6
dumb
=
{
.
sin6_family
=
ptr
->
ai_addr
->
sa_family
,
.
sin6_port
=
((
struct
sockaddr_in
*
)(
ptr
->
ai_addr
))
->
sin_port
};
bind
(
fd
,
(
struct
sockaddr
*
)
&
dumb
,
ptr
->
ai_addrlen
);
}
else
#endif
if
(
bind
(
fd
,
ptr
->
ai_addr
,
ptr
->
ai_addrlen
))
{
net_Close
(
fd
);
fd
=
net_SetupDgramSocket
(
obj
,
fd
,
ptr
);
if
(
fd
==
-
1
)
continue
;
}
val
=
-
1
;
for
(
struct
addrinfo
*
ptr2
=
rem
;
ptr2
!=
NULL
;
ptr2
=
ptr2
->
ai_next
)
...
...
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