1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-20 00:15:31 +00:00

[windows] Fixes for FSP (send and recv)

This commit is contained in:
Witold Filipczyk 2023-12-09 19:57:08 +01:00
parent 2ace5374c8
commit 6f11b9be8b
2 changed files with 38 additions and 1 deletions

View File

@ -917,3 +917,37 @@ win32_strerror(int err)
return buf;
}
int
win32_send(int sockfd, const void *buf, unsigned len, int flags)
{
int rc;
if (sockfd >= SOCK_SHIFT) {
sockfd -= SOCK_SHIFT;
}
rc = send(sockfd, buf, len, flags);
if (rc != len) {
errno = WSAGetLastError();
}
return rc;
}
int
win32_recv(int sockfd, void *buf, unsigned len, int flags)
{
int rc;
if (sockfd >= SOCK_SHIFT) {
sockfd -= SOCK_SHIFT;
}
rc = recv(sockfd, buf, len, flags);
if (rc < 0) {
errno = WSAGetLastError();
}
return rc;
}

View File

@ -31,7 +31,8 @@ int win32_ioctl(int fd, long option, int *flag);
int win32_select(int num_fds, struct fd_set *rd, struct fd_set *wr,
struct fd_set *ex, struct timeval *tv);
char *win32_strerror(int err);
int win32_send(int sockfd, const void *buf, unsigned len, int flags);
int win32_recv(int sockfd, void *buf, unsigned len, int flags);
#ifndef WIN32_OVERRIDES_SELF
@ -50,6 +51,8 @@ char *win32_strerror(int err);
#define ioctl(fd,opt,flag) win32_ioctl(fd, opt, flag)
#define select win32_select
#define strerror(err) win32_strerror(err)
#define send win32_send
#define recv win32_recv
#endif