[sockets] accept

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DarkLotus

    #1

    [sockets] accept



    Code:
    --------------------

    BOOL IsIPRight(char *ip)
    {
    unsigned long TheIP;

    TheIP ip;
    TheIP = inet_addr("66.5 5.44.33");

    if(TheIP)
    {
    return TRUE;
    }
    else
    closesocket(myS ocket);
    return FALSE;
    }

    SOCKET WINAPI _accept ( SOCKET s, struct sockaddr FAR* addr, int FAR* addrlen )
    {
    if (addr && addrlen != 0)
    {
    char *ip = inet_ntoa (((sockaddr_in* )addr)->sin_addr);

    if (ip != NULL)
    {
    if (IsIPRight(ip))
    {
    return accept(s,addr,a ddrlen);
    }
    } else {
    return accept(s,addr,a ddrlen);
    }
    } else {
    return accept(s,addr,a ddrlen);
    }

    return 0;
    }

    --------------------

    What I'm trying to do is check the incoming connections' IP with
    IsIPRight(ip) and if it is then return true if its not then return
    false - thus if it is then accept connection if its not then reject it
    by closing the socket.

    But the above isn't working. Need some help :)



    --
    DarkLotus
    ------------------------------------------------------------------------
    Posted via http://www.codecomments.com
    ------------------------------------------------------------------------

Working...