fix socket.c

This commit is contained in:
Green Sky 2023-11-22 23:11:45 +01:00
parent 9da166ea34
commit 3b3b50b7ec
No known key found for this signature in database

View File

@ -21,6 +21,8 @@
#include <arpa/inet.h>
#include <netinet/in.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#define IS_SOCKET_ERROR(a) ((a)<0)
typedef int socket_t;
@ -99,10 +101,10 @@ static int socket_connect (socket_t * sock, const struct sockaddr *saddr, sockle
{
while ( 1 )
{
if ( connect (*sock, saddr, len) < 0 )
{
if ( socket_error() == EINTR )
continue;
if ( connect (*sock, saddr, len) < 0 )
{
if ( socket_error() == EINTR )
continue;
if ( socket_error() != EINPROGRESS && socket_error() != EWOULDBLOCK )
return 1;
@ -117,8 +119,8 @@ static int socket_accept (socket_t * sock, socket_t * newsock, struct sockaddr *
{
while ( IS_SOCKET_ERROR(*newsock = accept (*sock, saddr, len)) )
{
if ( socket_error() == EINTR )
continue;
if ( socket_error() == EINTR )
continue;
return 1;
}