Fix #17638 - Fix http server by using TCP in RSocket's protocol ##remote (#17641)

Co-authored-by: meme <meme@users.noreply.github.com>
This commit is contained in:
Keegan S 2020-09-15 05:22:04 -04:00 committed by GitHub
parent 797b937175
commit 36e9314832
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -82,7 +82,7 @@ typedef struct r_socket_http_options {
bool httpauth;
} RSocketHTTPOptions;
#define R_SOCKET_PROTO_DEFAULT 0
#define R_SOCKET_PROTO_TCP IPPROTO_TCP
#define R_SOCKET_PROTO_UDP IPPROTO_UDP
#define R_SOCKET_PROTO_UNIX 0x1337

View File

@ -496,6 +496,9 @@ R_API bool r_socket_listen(RSocket *s, const char *port, const char *certfile) {
#endif
switch (s->proto) {
case R_SOCKET_PROTO_DEFAULT:
s->proto = R_SOCKET_PROTO_TCP;
/* fallthrough */
case R_SOCKET_PROTO_TCP:
if ((s->fd = socket (AF_INET, SOCK_STREAM, R_SOCKET_PROTO_TCP)) == R_INVALID_SOCKET) {
return false;
@ -507,7 +510,8 @@ R_API bool r_socket_listen(RSocket *s, const char *port, const char *certfile) {
}
break;
default:
break;
eprintf ("Invalid protocol for socket\n");
return false;
}
linger.l_onoff = 1;
@ -550,6 +554,7 @@ R_API bool r_socket_listen(RSocket *s, const char *port, const char *certfile) {
#endif
if (s->proto == R_SOCKET_PROTO_TCP) {
if (listen (s->fd, 32) < 0) {
r_sys_perror ("listen");
#ifdef _MSC_VER
closesocket (s->fd);
#else