socket never closed

I try using this code to make shure that the socket is closed, but it never gets closed…
I successfully get an IP from DHCP. sockstate returns ‘Not an active socket!’

Don’t know why or what to do… Does anyone have an idea?

typedef struct
{
    tcp_Socket socket;
   ...
} connection;

...
connection conn;
...

main()
{
    ...
    sock_init();
    ...

    while (sock_alive(&(conn.socket)))
    {
        sock_abort(&(conn.socket));
        waitfor(DelaySec(1));
    }

forgot to mention… sock_init is called before that and I successfully get IP from DHCP… sockstate returns ‘Not an active socket!’…

I investigated thing a bit and found out that probably the sockets are not initialized right. The ip_type in the socket array is not ‘0’, ‘1’ or ‘2’ at the beginning so sock_alive is always > ‘0’ and sock_abort never sets it to ‘0’… Any idea why?

I had the same problem. I couldn’t detect the close state neither by tcp_tick or socket_alive. They never return 0 and I stuck in the while loop also.
However I just tried using sockstate with the while loop tests for ‘Closed’. It works.
Let me know of yours.
Regards
Frank