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
5f5d7794
Commit
5f5d7794
authored
Jan 09, 2010
by
Antoine Cellerier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove timeout parameter from lua listner:accept().
parent
7ef39293
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
34 deletions
+7
-34
modules/misc/lua/libs/net.c
modules/misc/lua/libs/net.c
+1
-29
share/lua/README.txt
share/lua/README.txt
+5
-4
share/lua/intf/modules/host.lua
share/lua/intf/modules/host.lua
+1
-1
No files found.
modules/misc/lua/libs/net.c
View file @
5f5d7794
...
...
@@ -139,35 +139,7 @@ static int vlclua_net_accept( lua_State *L )
{
vlc_object_t
*
p_this
=
vlclua_get_this
(
L
);
int
**
ppi_fd
=
(
int
**
)
luaL_checkudata
(
L
,
1
,
"net_listen"
);
int
*
pi_fd
=
*
ppi_fd
;
int
i_timeout
=
luaL_optint
(
L
,
2
,
-
1
);
/* block is default */
/* Implement net_Accept with timeout */
int
i_fd
=
-
1
;
unsigned
int
i_count
=
1
;
while
(
pi_fd
[
i_count
]
!=
-
1
)
i_count
++
;
struct
pollfd
ufd
[
i_count
+
1
];
unsigned
int
i
;
for
(
i
=
0
;
i
<
i_count
;
i
++
)
{
ufd
[
i
].
fd
=
pi_fd
[
i
];
ufd
[
i
].
events
=
POLLIN
;
}
if
(
poll
(
ufd
,
i_count
,
i_timeout
)
>
0
)
{
for
(
i
=
0
;
i
<
i_count
;
i
++
)
{
if
(
!
ufd
[
i
].
revents
)
continue
;
i_fd
=
net_AcceptSingle
(
p_this
,
ufd
[
i
].
fd
);
if
(
i_fd
==
-
1
)
continue
;
memmove
(
pi_fd
+
i
,
pi_fd
+
i
+
1
,
i_count
-
(
i
+
1
)
);
pi_fd
[
i_count
-
1
]
=
ufd
[
i
].
fd
;
}
}
int
i_fd
=
net_Accept
(
p_this
,
*
ppi_fd
);
lua_pushinteger
(
L
,
i_fd
);
return
1
;
...
...
share/lua/README.txt
View file @
5f5d7794
...
...
@@ -112,12 +112,13 @@ net.url_parse( url, [option delimiter] ): Parse URL. Returns a table with
fields "protocol", "username", "password", "host", "port", path" and
"option".
net.listen_tcp( host, port ): Listen to TCP connections. This returns an
object with an accept and an fds method. The accept takes an optional timeout
argument (in milliseconds). The fds method returns a list of fds you can call
select on before using the accept method. For example:
object with an accept and an fds method. accept is blocking (Poll on the
fds with the net.POLLIN flag if you want to be non blockin).
The fds method returns a list of fds you can call select on before using
the accept method. For example:
local l = vlc.net.listen_tcp( "localhost", 1234 )
while true do
local fd = l:accept(
500
)
local fd = l:accept()
if fd >= 0 do
net.send( fd, "blabla" )
net.close( fd )
...
...
share/lua/intf/modules/host.lua
View file @
5f5d7794
...
...
@@ -258,7 +258,7 @@ function host()
for
_
,
listener
in
pairs
(
listeners
.
tcp
.
list
)
do
for
_
,
fd
in
pairs
({
listener
:
fds
()})
do
if
pollfds
[
fd
]
==
vlc
.
net
.
POLLIN
then
local
afd
=
listener
:
accept
(
0
)
local
afd
=
listener
:
accept
()
new_client
(
h
,
afd
,
afd
,
client_type
.
net
)
break
end
...
...
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