/* The socket function closes a created socket. 
closesocket */
INT32 CC3000_EXPORT() closesocket(INT32 sd)
/* The socket function closes a created socket. 
closesocket */
INT32 CC3000_EXPORT() closesocket(INT32 sd)
{
	INT32 ret;
	UINT8 *ptr, *args;
	ret = EFAIL;
	ptr = tSLInformation.pucTxCommandBuffer;
	args = (ptr + HEADERS_SIZE_CMD);
	args = UINT32_TO_STREAM(args, sd);
	hci_command_send(HCI_CMND_CLOSE_SOCKET,
		ptr, SOCKET_CLOSE_PARAMS_LEN);
	SimpleLinkWaitEvent(HCI_CMND_CLOSE_SOCKET, &ret);
	CC3000_EXPORT(errno) = ret;
	set_socket_active_status(sd, SOCKET_STATUS_INACTIVE);
	return(ret);
}