|
Packit |
549fdc |
/* listen.c --- wrappers for Windows listen function
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
Copyright (C) 2008-2016 Free Software Foundation, Inc.
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
This program is free software: you can redistribute it and/or modify
|
|
Packit |
549fdc |
it under the terms of the GNU General Public License as published by
|
|
Packit |
549fdc |
the Free Software Foundation; either version 3 of the License, or
|
|
Packit |
549fdc |
(at your option) any later version.
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
This program is distributed in the hope that it will be useful,
|
|
Packit |
549fdc |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
549fdc |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
549fdc |
GNU General Public License for more details.
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
You should have received a copy of the GNU General Public License
|
|
Packit |
549fdc |
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
/* Written by Paolo Bonzini */
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
#include <config.h>
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
#define WIN32_LEAN_AND_MEAN
|
|
Packit |
549fdc |
/* Get winsock2.h. */
|
|
Packit |
549fdc |
#include <sys/socket.h>
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
/* Get set_winsock_errno, FD_TO_SOCKET etc. */
|
|
Packit |
549fdc |
#include "w32sock.h"
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
#undef listen
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
int
|
|
Packit |
549fdc |
rpl_listen (int fd, int backlog)
|
|
Packit |
549fdc |
{
|
|
Packit |
549fdc |
SOCKET sock = FD_TO_SOCKET (fd);
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
if (sock == INVALID_SOCKET)
|
|
Packit |
549fdc |
{
|
|
Packit |
549fdc |
errno = EBADF;
|
|
Packit |
549fdc |
return -1;
|
|
Packit |
549fdc |
}
|
|
Packit |
549fdc |
else
|
|
Packit |
549fdc |
{
|
|
Packit |
549fdc |
int r = listen (sock, backlog);
|
|
Packit |
549fdc |
if (r < 0)
|
|
Packit |
549fdc |
set_winsock_errno ();
|
|
Packit |
549fdc |
|
|
Packit |
549fdc |
return r;
|
|
Packit |
549fdc |
}
|
|
Packit |
549fdc |
}
|