Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
d79d0aa1
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d79d0aa1
编写于
5月 29, 2012
作者:
J
Jeff Olson
提交者:
Brian Anderson
6月 29, 2012
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
std: some cleanup in net::tcp rename listen_to_conn->listen
上级
68e129dc
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
29 deletion
+30
-29
src/libstd/net_tcp.rs
src/libstd/net_tcp.rs
+30
-29
未找到文件。
src/libstd/net_tcp.rs
浏览文件 @
d79d0aa1
...
...
@@ -19,7 +19,7 @@
// operations on a tcp_socket
export
write
,
write_future
,
read_start
,
read_stop
;
// tcp server stuff
export
listen
_for_conn
,
accept
;
export
listen
,
accept
;
// tcp client stuff
export
connect
;
// helper methods
...
...
@@ -676,7 +676,7 @@ fn accept(new_conn: tcp_new_connection)
successful/normal shutdown, and a `tcp_err_data` record in the event
of listen exiting because of an error
"
]
fn
listen
_for_conn
(
host_ip
:
ip
::
ip_addr
,
port
:
uint
,
backlog
:
uint
,
fn
listen
(
host_ip
:
ip
::
ip_addr
,
port
:
uint
,
backlog
:
uint
,
iotask
:
iotask
,
on_establish_cb
:
fn
~
(
comm
::
chan
<
option
<
tcp_err_data
>>
),
+
new_connect_cb
:
fn
~
(
tcp_new_connection
,
...
...
@@ -697,47 +697,48 @@ fn listen_for_conn(host_ip: ip::ip_addr, port: uint, backlog: uint,
};
let
server_data_ptr
=
ptr
::
addr_of
(
server_data
);
let
setup_po
=
comm
::
port
::
<
option
<
tcp_err_data
>>
();
let
setup_ch
=
comm
::
chan
(
setup_po
);
iotask
::
interact
(
iotask
)
{|
loop_ptr
|
let
tcp_addr
=
ipv4_ip_addr_to_sockaddr_in
(
host_ip
,
port
);
alt
uv
::
ll
::
tcp_init
(
loop_ptr
,
server_stream_ptr
)
{
0i32
{
alt
uv
::
ll
::
tcp_bind
(
server_stream_ptr
,
ptr
::
addr_of
(
tcp_addr
))
{
let
setup_result
=
comm
::
listen
{|
setup_ch
|
iotask
::
interact
(
iotask
)
{|
loop_ptr
|
let
tcp_addr
=
ipv4_ip_addr_to_sockaddr_in
(
host_ip
,
port
);
alt
uv
::
ll
::
tcp_init
(
loop_ptr
,
server_stream_ptr
)
{
0i32
{
alt
uv
::
ll
::
listen
(
server_stream_ptr
,
backlog
as
libc
::
c_int
,
tcp_lfc_on_connection_cb
)
{
alt
uv
::
ll
::
tcp_bind
(
server_stream_ptr
,
ptr
::
addr_of
(
tcp_addr
))
{
0i32
{
uv
::
ll
::
set_data_for_uv_handle
(
server_stream_ptr
,
server_data_ptr
);
comm
::
send
(
setup_ch
,
none
);
alt
uv
::
ll
::
listen
(
server_stream_ptr
,
backlog
as
libc
::
c_int
,
tcp_lfc_on_connection_cb
)
{
0i32
{
uv
::
ll
::
set_data_for_uv_handle
(
server_stream_ptr
,
server_data_ptr
);
comm
::
send
(
setup_ch
,
none
);
}
_
{
log
(
debug
,
"failure to uv_listen()"
);
let
err_data
=
uv
::
ll
::
get_last_err_data
(
loop_ptr
);
comm
::
send
(
setup_ch
,
some
(
err_data
));
}
}
}
_
{
log
(
debug
,
"failure to uv_
listen()
"
);
log
(
debug
,
"failure to uv_
tcp_bind
"
);
let
err_data
=
uv
::
ll
::
get_last_err_data
(
loop_ptr
);
comm
::
send
(
setup_ch
,
some
(
err_data
));
}
}
}
_
{
log
(
debug
,
"failure to uv_tcp_
bind
"
);
log
(
debug
,
"failure to uv_tcp_
init
"
);
let
err_data
=
uv
::
ll
::
get_last_err_data
(
loop_ptr
);
comm
::
send
(
setup_ch
,
some
(
err_data
));
}
}
}
_
{
log
(
debug
,
"failure to uv_tcp_init"
);
let
err_data
=
uv
::
ll
::
get_last_err_data
(
loop_ptr
);
comm
::
send
(
setup_ch
,
some
(
err_data
));
}
}
};
setup_ch
.recv
()
};
alt
comm
::
recv
(
setup_po
)
{
alt
setup_result
{
some
(
err_data
)
{
// we failed to bind/list w/ libuv
result
::
err
(
err_data
.to_tcp_err
())
...
...
@@ -1338,7 +1339,7 @@ fn run_tcp_test_server(server_ip: str, server_port: uint, resp: str,
task
::
spawn_sched
(
task
::
manual_threads
(
1u
))
{||
let
server_ip_addr
=
ip
::
v4
::
parse_addr
(
server_ip
);
let
listen_result
=
listen
_for_conn
(
server_ip_addr
,
server_port
,
128u
,
listen
(
server_ip_addr
,
server_port
,
128u
,
iotask
,
// on_establish_cb -- called when listener is set up
{|
kill_ch
|
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录