Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libnice
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
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
cpp-libs
libnice
Commits
146ce0f8
Commit
146ce0f8
authored
Feb 23, 2012
by
Livio Madaro
Committed by
Youness Alaoui
Feb 23, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set nonblocking mode for socket on Windows
parent
7973ba49
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
+19
-2
socket/tcp-bsd.c
socket/tcp-bsd.c
+8
-2
socket/udp-bsd.c
socket/udp-bsd.c
+5
-0
stun/usages/bind.c
stun/usages/bind.c
+6
-0
No files found.
socket/tcp-bsd.c
View file @
146ce0f8
...
...
@@ -93,6 +93,9 @@ nice_tcp_bsd_socket_new (GMainContext *ctx, NiceAddress *addr)
socklen_t
name_len
=
sizeof
(
name
);
NiceSocket
*
sock
;
TcpPriv
*
priv
;
#ifdef G_OS_WIN32
unsigned
long
set_nonblock
=
1
;
#endif
if
(
addr
==
NULL
)
{
/* We can't connect a tcp socket with no destination address */
...
...
@@ -129,6 +132,8 @@ nice_tcp_bsd_socket_new (GMainContext *ctx, NiceAddress *addr)
#endif
#ifdef O_NONBLOCK
fcntl
(
sockfd
,
F_SETFL
,
fcntl
(
sockfd
,
F_GETFL
)
|
O_NONBLOCK
);
#elif defined G_OS_WIN32
ioctlsocket
(
sockfd
,
FIONBIO
,
&
set_nonblock
);
#endif
name_len
=
name
.
ss_family
==
AF_INET
?
sizeof
(
struct
sockaddr_in
)
:
...
...
@@ -136,7 +141,7 @@ nice_tcp_bsd_socket_new (GMainContext *ctx, NiceAddress *addr)
ret
=
connect
(
sockfd
,
(
const
struct
sockaddr
*
)
&
name
,
name_len
);
#ifdef G_OS_WIN32
if
(
ret
<
0
&&
WSAGetLastError
()
!=
WSAE
INPROGRESS
)
{
if
(
ret
<
0
&&
WSAGetLastError
()
!=
WSAE
WOULDBLOCK
)
{
closesocket
(
sockfd
);
#else
if
(
ret
<
0
&&
errno
!=
EINPROGRESS
)
{
...
...
@@ -258,7 +263,8 @@ socket_send (NiceSocket *sock, const NiceAddress *to,
if
(
ret
<
0
)
{
#ifdef G_OS_WIN32
if
(
WSAGetLastError
()
==
WSAEWOULDBLOCK
)
{
if
(
WSAGetLastError
()
==
WSAEWOULDBLOCK
||
WSAGetLastError
()
==
WSAENOTCONN
)
{
#else
if
(
errno
==
EAGAIN
)
{
#endif
...
...
socket/udp-bsd.c
View file @
146ce0f8
...
...
@@ -70,6 +70,9 @@ nice_udp_bsd_socket_new (NiceAddress *addr)
struct
sockaddr_storage
name
;
socklen_t
name_len
=
sizeof
(
name
);
NiceSocket
*
sock
=
g_slice_new0
(
NiceSocket
);
#ifdef G_OS_WIN32
unsigned
long
set_nonblock
=
1
;
#endif
if
(
addr
!=
NULL
)
{
nice_address_copy_to_sockaddr
(
addr
,
(
struct
sockaddr
*
)
&
name
);
...
...
@@ -102,6 +105,8 @@ nice_udp_bsd_socket_new (NiceAddress *addr)
#endif
#ifdef O_NONBLOCK
fcntl
(
sockfd
,
F_SETFL
,
fcntl
(
sockfd
,
F_GETFL
)
|
O_NONBLOCK
);
#elif defined G_OS_WIN32
ioctlsocket
(
sockfd
,
FIONBIO
,
&
set_nonblock
);
#endif
if
(
bind
(
sockfd
,
(
struct
sockaddr
*
)
&
name
,
...
...
stun/usages/bind.c
View file @
146ce0f8
...
...
@@ -227,6 +227,10 @@ stun_trans_init (StunTransport *tr, int fd,
*/
static
int
stun_socket
(
int
family
,
int
type
,
int
proto
)
{
#ifdef _WIN32
unsigned
long
set_nonblock
=
1
;
#endif
int
fd
=
socket
(
family
,
type
,
proto
);
if
(
fd
==
-
1
)
return
-
1
;
...
...
@@ -236,6 +240,8 @@ static int stun_socket (int family, int type, int proto)
#endif
#ifdef O_NONBLOCK
fcntl
(
fd
,
F_SETFL
,
fcntl
(
fd
,
F_GETFL
)
|
O_NONBLOCK
);
#elif defined _WIN32
ioctlsocket
(
fd
,
FIONBIO
,
&
set_nonblock
);
#endif
#ifdef MSG_ERRQUEUE
...
...
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