Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Xiph.Org
Icecast-Server
Commits
9c155dda
Commit
9c155dda
authored
Oct 24, 2007
by
Karl Heyes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up prototypes and sock_t handling, for win32 mainly, no functional change
svn path=/icecast/trunk/net/; revision=14041
parent
4b5f0099
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
28 deletions
+30
-28
src/net/sock.c
src/net/sock.c
+19
-19
src/net/sock.h
src/net/sock.h
+11
-9
No files found.
src/net/sock.c
View file @
9c155dda
...
...
@@ -305,14 +305,14 @@ int sock_close(sock_t sock)
*/
#ifdef HAVE_WRITEV
ssize_t
sock_writev
(
in
t
sock
,
const
struct
iovec
*
iov
,
const
size_t
count
)
ssize_t
sock_writev
(
sock_
t
sock
,
const
struct
iovec
*
iov
,
size_t
count
)
{
return
writev
(
sock
,
iov
,
count
);
}
#else
ssize_t
sock_writev
(
in
t
sock
,
const
struct
iovec
*
iov
,
const
size_t
count
)
ssize_t
sock_writev
(
sock_
t
sock
,
const
struct
iovec
*
iov
,
size_t
count
)
{
int
i
=
count
,
accum
=
0
,
ret
;
const
struct
iovec
*
v
=
iov
;
...
...
@@ -343,7 +343,7 @@ ssize_t sock_writev (int sock, const struct iovec *iov, const size_t count)
** write bytes to the socket
** this function will _NOT_ block
*/
int
sock_write_bytes
(
sock_t
sock
,
const
void
*
buff
,
const
size_t
len
)
int
sock_write_bytes
(
sock_t
sock
,
const
void
*
buff
,
size_t
len
)
{
/* sanity check */
if
(
!
buff
)
{
...
...
@@ -449,7 +449,7 @@ int sock_write_fmt(sock_t sock, const char *fmt, va_list ap)
#endif
int
sock_read_bytes
(
sock_t
sock
,
char
*
buff
,
const
in
t
len
)
int
sock_read_bytes
(
sock_t
sock
,
char
*
buff
,
size_
t
len
)
{
/*if (!sock_valid_socket(sock)) return 0; */
...
...
@@ -508,7 +508,7 @@ int sock_read_line(sock_t sock, char *buff, const int len)
* return 0 for try again, interrupted
* return 1 for ok
*/
int
sock_connected
(
in
t
sock
,
int
timeout
)
int
sock_connected
(
sock_
t
sock
,
int
timeout
)
{
fd_set
wfds
;
int
val
=
SOCK_ERROR
;
...
...
@@ -548,7 +548,7 @@ int sock_connected (int sock, int timeout)
#ifdef HAVE_GETADDRINFO
in
t
sock_connect_non_blocking
(
const
char
*
hostname
,
const
unsigned
port
)
sock_
t
sock_connect_non_blocking
(
const
char
*
hostname
,
const
unsigned
port
)
{
int
sock
=
SOCK_ERROR
;
struct
addrinfo
*
ai
,
*
head
,
hints
;
...
...
@@ -592,7 +592,7 @@ int sock_connect_non_blocking (const char *hostname, const unsigned port)
*/
sock_t
sock_connect_wto
(
const
char
*
hostname
,
int
port
,
int
timeout
)
{
in
t
sock
=
SOCK_ERROR
;
sock_
t
sock
=
SOCK_ERROR
;
struct
addrinfo
*
ai
,
*
head
,
hints
;
char
service
[
8
];
...
...
@@ -693,7 +693,7 @@ sock_t sock_get_server_socket (int port, const char *sinterface)
#else
int
sock_try_connection
(
in
t
sock
,
const
char
*
hostname
,
const
unsigned
port
)
int
sock_try_connection
(
sock_
t
sock
,
const
char
*
hostname
,
const
unsigned
port
)
{
struct
sockaddr_in
sin
,
server
;
char
ip
[
MAX_ADDR_LEN
];
...
...
@@ -724,13 +724,13 @@ int sock_try_connection (int sock, const char *hostname, const unsigned port)
return
connect
(
sock
,
(
struct
sockaddr
*
)
&
server
,
sizeof
(
server
));
}
in
t
sock_connect_non_blocking
(
const
char
*
hostname
,
const
unsigned
port
)
sock_
t
sock_connect_non_blocking
(
const
char
*
hostname
,
unsigned
port
)
{
in
t
sock
;
sock_
t
sock
;
sock
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
if
(
sock
==
-
1
)
return
-
1
;
if
(
sock
==
SOCK_ERROR
)
return
SOCK_ERROR
;
sock_set_blocking
(
sock
,
SOCK_NONBLOCK
);
sock_try_connection
(
sock
,
hostname
,
port
);
...
...
@@ -738,13 +738,13 @@ int sock_connect_non_blocking (const char *hostname, const unsigned port)
return
sock
;
}
sock_t
sock_connect_wto
(
const
char
*
hostname
,
const
int
port
,
const
int
timeout
)
sock_t
sock_connect_wto
(
const
char
*
hostname
,
int
port
,
int
timeout
)
{
in
t
sock
;
sock_
t
sock
;
sock
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
if
(
sock
==
-
1
)
return
-
1
;
if
(
sock
==
SOCK_ERROR
)
return
SOCK_ERROR
;
if
(
timeout
)
{
...
...
@@ -838,14 +838,14 @@ int sock_listen(sock_t serversock, int backlog)
return
(
listen
(
serversock
,
backlog
)
==
0
);
}
in
t
sock_accept
(
sock_t
serversock
,
char
*
ip
,
size_t
len
)
sock_
t
sock_accept
(
sock_t
serversock
,
char
*
ip
,
size_t
len
)
{
#ifdef HAVE_GETNAMEINFO
struct
sockaddr_storage
sa
;
#else
struct
sockaddr_in
sa
;
#endif
in
t
ret
;
sock_
t
ret
;
socklen_t
slen
;
if
(
ip
==
NULL
||
len
==
0
||
!
sock_valid_socket
(
serversock
))
...
...
@@ -854,7 +854,7 @@ int sock_accept(sock_t serversock, char *ip, size_t len)
slen
=
sizeof
(
sa
);
ret
=
accept
(
serversock
,
(
struct
sockaddr
*
)
&
sa
,
&
slen
);
if
(
ret
>
=
0
)
if
(
ret
!
=
SOCK_ERROR
)
{
#ifdef HAVE_GETNAMEINFO
if
(
getnameinfo
((
struct
sockaddr
*
)
&
sa
,
slen
,
ip
,
len
,
NULL
,
0
,
NI_NUMERICHOST
))
...
...
src/net/sock.h
View file @
9c155dda
...
...
@@ -56,11 +56,13 @@ struct iovec
#define MAX_ADDR_LEN 46
#endif
typedef
int
sock_t
;
#ifndef sock_t
#define sock_t int
#endif
/* The following values are based on unix avoiding errno value clashes */
#define SOCK_SUCCESS 0
#define SOCK_ERROR -1
#define SOCK_ERROR
(sock_t)
-1
#define SOCK_TIMEOUT -2
#define SOCK_BLOCK 0
...
...
@@ -113,26 +115,26 @@ int sock_set_nodelay(sock_t sock);
int
sock_close
(
sock_t
sock
);
/* Connection related socket functions */
sock_t
sock_connect_wto
(
const
char
*
hostname
,
const
int
port
,
const
int
timeout
);
in
t
sock_connect_non_blocking
(
const
char
*
host
,
const
unsigned
port
);
int
sock_connected
(
in
t
sock
,
int
timeout
);
sock_t
sock_connect_wto
(
const
char
*
hostname
,
int
port
,
int
timeout
);
sock_
t
sock_connect_non_blocking
(
const
char
*
host
,
unsigned
port
);
int
sock_connected
(
sock_
t
sock
,
int
timeout
);
/* Socket write functions */
int
sock_write_bytes
(
sock_t
sock
,
const
void
*
buff
,
const
size_t
len
);
int
sock_write_bytes
(
sock_t
sock
,
const
void
*
buff
,
size_t
len
);
int
sock_write
(
sock_t
sock
,
const
char
*
fmt
,
...);
int
sock_write_fmt
(
sock_t
sock
,
const
char
*
fmt
,
va_list
ap
);
int
sock_write_string
(
sock_t
sock
,
const
char
*
buff
);
ssize_t
sock_writev
(
in
t
sock
,
const
struct
iovec
*
iov
,
const
size_t
count
);
ssize_t
sock_writev
(
sock_
t
sock
,
const
struct
iovec
*
iov
,
size_t
count
);
/* Socket read functions */
int
sock_read_bytes
(
sock_t
sock
,
char
*
buff
,
const
in
t
len
);
int
sock_read_bytes
(
sock_t
sock
,
char
*
buff
,
size_
t
len
);
int
sock_read_line
(
sock_t
sock
,
char
*
string
,
const
int
len
);
/* server socket functions */
sock_t
sock_get_server_socket
(
int
port
,
const
char
*
sinterface
);
int
sock_listen
(
sock_t
serversock
,
int
backlog
);
in
t
sock_accept
(
sock_t
serversock
,
char
*
ip
,
size_t
len
);
sock_
t
sock_accept
(
sock_t
serversock
,
char
*
ip
,
size_t
len
);
#ifdef _WIN32
int
inet_aton
(
const
char
*
s
,
struct
in_addr
*
a
);
...
...
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