Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-11-17 10:27:05 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9f60a6738abeb98ece5d16548ad47409f3a4da8e
9f60a673
1 parent
520764fb
add comments for listen
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
14 行增加
和
14 行删除
trunk/src/app/srs_app_server.cpp
trunk/src/app/srs_app_server.cpp
查看文件 @
9f60a67
...
...
@@ -130,18 +130,18 @@ int SrsListener::listen(int port)
if
((
fd
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
))
==
-
1
)
{
ret
=
ERROR_SOCKET_CREATE
;
srs_error
(
"create linux socket error.
ret=%d"
,
ret
);
srs_error
(
"create linux socket error.
port=%d, ret=%d"
,
port
,
ret
);
return
ret
;
}
srs_verbose
(
"create linux socket success.
fd=%d"
,
fd
);
srs_verbose
(
"create linux socket success.
port=%d, fd=%d"
,
port
,
fd
);
int
reuse_socket
=
1
;
if
(
setsockopt
(
fd
,
SOL_SOCKET
,
SO_REUSEADDR
,
&
reuse_socket
,
sizeof
(
int
))
==
-
1
)
{
ret
=
ERROR_SOCKET_SETREUSE
;
srs_error
(
"setsockopt reuse-addr error.
ret=%d"
,
ret
);
srs_error
(
"setsockopt reuse-addr error.
port=%d, ret=%d"
,
port
,
ret
);
return
ret
;
}
srs_verbose
(
"setsockopt reuse-addr success.
fd=%d"
,
fd
);
srs_verbose
(
"setsockopt reuse-addr success.
port=%d, fd=%d"
,
port
,
fd
);
sockaddr_in
addr
;
addr
.
sin_family
=
AF_INET
;
...
...
@@ -149,34 +149,34 @@ int SrsListener::listen(int port)
addr
.
sin_addr
.
s_addr
=
INADDR_ANY
;
if
(
bind
(
fd
,
(
const
sockaddr
*
)
&
addr
,
sizeof
(
sockaddr_in
))
==
-
1
)
{
ret
=
ERROR_SOCKET_BIND
;
srs_error
(
"bind socket error.
ret=%d"
,
ret
);
srs_error
(
"bind socket error.
port=%d, ret=%d"
,
port
,
ret
);
return
ret
;
}
srs_verbose
(
"bind socket success.
fd=%d"
,
fd
);
srs_verbose
(
"bind socket success.
port=%d, fd=%d"
,
port
,
fd
);
if
(
::
listen
(
fd
,
SERVER_LISTEN_BACKLOG
)
==
-
1
)
{
ret
=
ERROR_SOCKET_LISTEN
;
srs_error
(
"listen socket error.
ret=%d"
,
ret
);
srs_error
(
"listen socket error.
port=%d, ret=%d"
,
port
,
ret
);
return
ret
;
}
srs_verbose
(
"listen socket success.
fd=%d"
,
fd
);
srs_verbose
(
"listen socket success.
port=%d, fd=%d"
,
port
,
fd
);
if
((
stfd
=
st_netfd_open_socket
(
fd
))
==
NULL
){
ret
=
ERROR_ST_OPEN_SOCKET
;
srs_error
(
"st_netfd_open_socket open socket failed.
ret=%d"
,
ret
);
srs_error
(
"st_netfd_open_socket open socket failed.
port=%d, ret=%d"
,
port
,
ret
);
return
ret
;
}
srs_verbose
(
"st open socket success.
fd=%d"
,
fd
);
srs_verbose
(
"st open socket success.
port=%d, fd=%d"
,
port
,
fd
);
if
((
ret
=
pthread
->
start
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"st_thread_create listen thread error.
ret=%d"
,
ret
);
srs_error
(
"st_thread_create listen thread error.
port=%d, ret=%d"
,
port
,
ret
);
return
ret
;
}
srs_verbose
(
"create st listen thread success
."
);
srs_verbose
(
"create st listen thread success
, port=%d"
,
port
);
srs_trace
(
"listen thread cid=%d, current_cid=%d, "
"listen at port=%d, type=%d, fd=%d started success"
,
pthread
->
cid
(),
_srs_context
->
get_id
(),
_port
,
_type
,
fd
);
"listen at port=%d, type=%d, fd=%d started success, port=%d"
,
pthread
->
cid
(),
_srs_context
->
get_id
(),
_port
,
_type
,
fd
,
port
);
return
ret
;
}
...
...
请
注册
或
登录
后发表评论