Socket functions needed when we switch to UDP.
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3662 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -80,7 +80,11 @@ int Socket_bind(Socket *sock, const struct sockaddr *addr,
|
||||
int Socket_listen(Socket *sock, int backlog);
|
||||
Socket *Socket_accept(Socket *sock, struct sockaddr *addr, socklen_t *addrLen);
|
||||
ssize_t Socket_send(Socket *sock, const void *buf, size_t len, int flags);
|
||||
ssize_t Socket_sendto(Socket *sock, const void *buf, size_t len, int flags,
|
||||
const struct sockaddr *addr, socklen_t addrLen);
|
||||
ssize_t Socket_recv(Socket *sock, void *buf, size_t len, int flags);
|
||||
ssize_t Socket_recvfrom(Socket *sock, void *buf, size_t len, int flags,
|
||||
struct sockaddr *from, socklen_t *fromLen);
|
||||
|
||||
int Socket_setNonBlocking(Socket *sock);
|
||||
int Socket_setReuseAddr(Socket *sock);
|
||||
|
||||
@@ -129,11 +129,23 @@ Socket_send(Socket *sock, const void *buf, size_t len, int flags) {
|
||||
return send(sock->fd, buf, len, flags);
|
||||
}
|
||||
|
||||
ssize_t
|
||||
Socket_sendto(Socket *sock, const void *buf, size_t len, int flags,
|
||||
const struct sockaddr *addr, socklen_t addrLen) {
|
||||
return sendto(sock->fd, buf, len, flags, addr, addrLen);
|
||||
}
|
||||
|
||||
ssize_t
|
||||
Socket_recv(Socket *sock, void *buf, size_t len, int flags) {
|
||||
return recv(sock->fd, buf, len, flags);
|
||||
}
|
||||
|
||||
ssize_t
|
||||
Socket_recvfrom(Socket *sock, void *buf, size_t len, int flags,
|
||||
struct sockaddr *from, socklen_t *fromLen) {
|
||||
return recvfrom(sock->fd, buf, len, flags, from, fromLen);
|
||||
}
|
||||
|
||||
int
|
||||
Socket_setNonBlocking(Socket *sock) {
|
||||
int flags;
|
||||
|
||||
@@ -159,6 +159,20 @@ Socket_send(Socket *sock, const void *buf, size_t len, int flags) {
|
||||
return sendResult;
|
||||
}
|
||||
|
||||
ssize_t
|
||||
Socket_sendto(Socket *sock, const void *buf, size_t len, int flags,
|
||||
const struct sockaddr *addr, socklen_t addrLen) {
|
||||
int sendResult;
|
||||
|
||||
sendResult = sendto(sock->sock, buf, len, flags, addr, addrLen);
|
||||
if (sendResult == SOCKET_ERROR) {
|
||||
errno = getWinsockErrno();
|
||||
return -1;
|
||||
}
|
||||
|
||||
return sendResult;
|
||||
}
|
||||
|
||||
ssize_t
|
||||
Socket_recv(Socket *sock, void *buf, size_t len, int flags) {
|
||||
int recvResult;
|
||||
@@ -172,6 +186,20 @@ Socket_recv(Socket *sock, void *buf, size_t len, int flags) {
|
||||
return recvResult;
|
||||
}
|
||||
|
||||
ssize_t
|
||||
Socket_recvfrom(Socket *sock, void *buf, size_t len, int flags,
|
||||
struct sockaddr *from, socklen_t *fromLen) {
|
||||
int recvResult;
|
||||
|
||||
recvResult = recvfrom(sock->sock, buf, len, flags, from, fromLen);
|
||||
if (recvResult == SOCKET_ERROR) {
|
||||
errno = getWinsockErrno();
|
||||
return -1;
|
||||
}
|
||||
|
||||
return recvResult;
|
||||
}
|
||||
|
||||
int
|
||||
Socket_setNonBlocking(Socket *sock) {
|
||||
unsigned long flag = 1;
|
||||
|
||||
Reference in New Issue
Block a user