fix socket.c
This commit is contained in:
parent
9da166ea34
commit
3b3b50b7ec
@ -21,6 +21,8 @@
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#define IS_SOCKET_ERROR(a) ((a)<0)
|
#define IS_SOCKET_ERROR(a) ((a)<0)
|
||||||
typedef int socket_t;
|
typedef int socket_t;
|
||||||
@ -99,10 +101,10 @@ static int socket_connect (socket_t * sock, const struct sockaddr *saddr, sockle
|
|||||||
{
|
{
|
||||||
while ( 1 )
|
while ( 1 )
|
||||||
{
|
{
|
||||||
if ( connect (*sock, saddr, len) < 0 )
|
if ( connect (*sock, saddr, len) < 0 )
|
||||||
{
|
{
|
||||||
if ( socket_error() == EINTR )
|
if ( socket_error() == EINTR )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ( socket_error() != EINPROGRESS && socket_error() != EWOULDBLOCK )
|
if ( socket_error() != EINPROGRESS && socket_error() != EWOULDBLOCK )
|
||||||
return 1;
|
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)) )
|
while ( IS_SOCKET_ERROR(*newsock = accept (*sock, saddr, len)) )
|
||||||
{
|
{
|
||||||
if ( socket_error() == EINTR )
|
if ( socket_error() == EINTR )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user