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
6726fdf0
Commit
6726fdf0
authored
Nov 06, 2004
by
Clément Stenac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added net_Select
parent
453217f4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
0 deletions
+86
-0
include/network.h
include/network.h
+4
-0
src/misc/net.c
src/misc/net.c
+82
-0
No files found.
include/network.h
View file @
6726fdf0
...
...
@@ -229,6 +229,10 @@ VLC_EXPORT( int, __net_Read, ( vlc_object_t *p_this, int fd, uint8_t *p_data, in
#define net_ReadNonBlock(a,b,c,d,e) __net_ReadNonBlock(VLC_OBJECT(a),b,c,d,e)
VLC_EXPORT
(
int
,
__net_ReadNonBlock
,
(
vlc_object_t
*
p_this
,
int
fd
,
uint8_t
*
p_data
,
int
i_data
,
mtime_t
i_wait
)
);
#define net_Select(a,b,c,d,e,f) __net_Select(VLC_OBJECT(a),b,c,d,e,f)
VLC_EXPORT
(
int
,
__net_Select
,
(
vlc_object_t
*
p_this
,
int
*
pi_fd
,
int
i_fd
,
uint8_t
*
p_data
,
int
i_data
,
mtime_t
i_wait
)
);
#define net_Write(a,b,c,d) __net_Write(VLC_OBJECT(a),b,c,d)
VLC_EXPORT
(
int
,
__net_Write
,
(
vlc_object_t
*
p_this
,
int
fd
,
uint8_t
*
p_data
,
int
i_data
)
);
...
...
src/misc/net.c
View file @
6726fdf0
...
...
@@ -448,6 +448,88 @@ int __net_ReadNonBlock( vlc_object_t *p_this, int fd, uint8_t *p_data,
return
-
1
;
}
/*****************************************************************************
* __net_Select:
*****************************************************************************
* Read from several sockets (with timeout)
*****************************************************************************/
int
__net_Select
(
vlc_object_t
*
p_this
,
int
*
pi_fd
,
int
i_fd
,
uint8_t
*
p_data
,
int
i_data
,
mtime_t
i_wait
)
{
struct
timeval
timeout
;
fd_set
fds_r
,
fds_e
;
int
i_recv
;
int
i_ret
;
int
i
;
int
i_max_fd
=
0
;
/* Initialize file descriptor set */
FD_ZERO
(
&
fds_r
);
FD_ZERO
(
&
fds_e
);
for
(
i
=
0
;
i
<
i_fd
;
i
++
)
{
if
(
pi_fd
[
i
]
>
i_max_fd
)
i_max_fd
=
pi_fd
[
i
];
FD_SET
(
pi_fd
[
i
],
&
fds_r
);
FD_SET
(
pi_fd
[
i
],
&
fds_e
);
}
timeout
.
tv_sec
=
0
;
timeout
.
tv_usec
=
i_wait
;
i_ret
=
select
(
i_max_fd
+
1
,
&
fds_r
,
NULL
,
&
fds_e
,
&
timeout
);
if
(
i_ret
<
0
&&
errno
==
EINTR
)
{
return
0
;
}
else
if
(
i_ret
<
0
)
{
msg_Err
(
p_this
,
"network select error (%s)"
,
strerror
(
errno
)
);
return
-
1
;
}
else
if
(
i_ret
==
0
)
{
return
0
;
}
else
{
for
(
i
=
0
;
i
<
i_fd
;
i
++
)
{
if
(
FD_ISSET
(
pi_fd
[
i
],
&
fds_r
)
)
{
i_recv
=
recv
(
pi_fd
[
i
],
p_data
,
i_data
,
0
);
if
(
i_recv
<=
0
)
{
#ifdef WIN32
/* For udp only */
/* On win32 recv() will fail if the datagram doesn't
* fit inside the passed buffer, even though the buffer
* will be filled with the first part of the datagram. */
if
(
WSAGetLastError
()
==
WSAEMSGSIZE
)
{
msg_Err
(
p_this
,
"recv() failed. "
"Increase the mtu size (--mtu option)"
);
}
else
msg_Err
(
p_this
,
"recv failed (%i)"
,
WSAGetLastError
()
);
#else
msg_Err
(
p_this
,
"recv failed (%s)"
,
strerror
(
errno
)
);
#endif
return
VLC_EGENERIC
;
}
return
i_recv
;
}
}
}
/* We will never be here */
return
-
1
;
}
/* Write exact amount requested */
int
__net_Write
(
vlc_object_t
*
p_this
,
int
fd
,
uint8_t
*
p_data
,
int
i_data
)
{
...
...
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