예제 #1
0
파일: sockets.c 프로젝트: 119/bcm-wiced-sdk
INT soc_close( INT sockID )
{
    switch ( sockets[sockID].type )
    {
        case BSD_SOCKET_TCP:
            nx_tcp_socket_disconnect( &sockets[sockID].socket.tcp, NX_WAIT_FOREVER );
            nx_tcp_server_socket_unaccept( &sockets[sockID].socket.tcp );

            if ( sockets[sockID].reuse == WICED_FALSE )
            {
                nx_tcp_server_socket_unlisten( sockets[sockID].socket.tcp.nx_tcp_socket_ip_ptr, sockets[sockID].socket.tcp.nx_tcp_socket_port );
                nx_tcp_client_socket_unbind( &sockets[sockID].socket.tcp );
                if ( nx_tcp_socket_delete( &sockets[sockID].socket.tcp ) != NX_SUCCESS )
                {
                    sockets[sockID].available = WICED_FALSE;
                }
                sockets[sockID].available = WICED_TRUE;
            }
            break;

        case BSD_SOCKET_UDP:
            if ( sockets[sockID].socket.udp.nx_udp_socket_bound_next )
            {
                nx_udp_socket_unbind( &sockets[sockID].socket.udp );
            }
            if ( nx_udp_socket_delete( &sockets[sockID].socket.udp ) != NX_SUCCESS )
            {
                sockets[sockID].available = WICED_FALSE;
            }
            sockets[sockID].available = WICED_TRUE;
            break;
    }
    return BSD_SUCCESS;
}
예제 #2
0
void s7g2_disconnect(Network* n) 
{
  n->byte_ip = 0;
  nx_tcp_socket_disconnect(&n->my_socket, 200);
  nx_tcp_client_socket_unbind(&n->my_socket);
  nx_tcp_socket_delete(&n->my_socket);
}